Common Board#include <iostream> #include <math.h> #include <vector> #include <stdlib.h> using namespace std; int main() { vector<double> v; int v1; while((cin>>v1)) { v.push_back(v1); } int size = v.size(); int first = v[0]; int last = v[size-1]; for(int i = size-1; i>=0; i--) { double a = sqrt(v[i]); printf("%.4lf\n", a); } return 0; } All forum tests passed, but wa:( Million thanks to someone who will help! upd: I have AC with this test: 0 2 1 1 Can someone tell me how I can solve thi problem using ordered set? What is test №36? I don't understand why my programm crash on test. Т.е. у этой задачи предполагается написание перебора с отсечениями? Последовательно добавляем символы в конец строки и если не смогли найти палиндрома, который бы являлся суффиксом новой строки, то дальше не перебираем? Hint: We must find pair for the first character or create it. If S[0] is ']' or ')', then we must add '[' or '(' in begin. If S[0] is '[' or '(', then we can find pair in S or add ']' or ')' after S[0]. Edited by author 26.06.2020 19:51 9 3 1 5 1 4 2 7 2 5 3 6 5 9 6 9 7 8 1 4 2 4 9 4 Answer: 8 (or 3) 3 8 3 5 5 5 1 5 7 ans 1 2 3 Thanks! It can help on wa 13 too! #include <bits/stdc++.h> #define gif(a,b) ((a)/(b)+((a)%(b)?1:0)) #define float long double #define int long long //#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define w(x) cout<<(#x)<<" is "<<(x)<<"\n"; using namespace std; int32_t main() { //IOS float a, r; cin >> a >> r; float theta = acos(a/(2*r));
float s = sin(theta);
float pi = acos(-1); if(a/2 > r) printf("%0.3Lf",pi*r*r); else if(r > a/pow(2, 0.5)) cout << a*a; else cout << (pi*r*r) - 4*(r*r*theta - a*r*s/2) ; return 0; } Проблема с точностью. исправьте "cout << (pi*r*r) - 4*(r*r*theta - a*r*s/2) ;" на "cout << fixed << setprecision(3) << (pi*r*r) - 4*(r*r*theta - a*r*s/2) ;". UPD: Попрошу не выкладывать свой код на форуме, он создан для обсуждения, а не для выкладывания на нем готовых решений. Поэтому прошу его убрать. Edited by author 22.06.2020 19:34 #include<bits/stdc++.h> using namespace std; int primes[300001],nprime; int mark[1000002]; #define MAX_SIZE 1000005 void sieve(){ int i,j,limit = sqrt(MAX_SIZE*1.0)+2; mark[1]=1; for(i=4;i<=MAX_SIZE;i+=2)mark[i]=1; primes[nprime++]=2; for(i=3;i<=MAX_SIZE;i+=2){ if(!mark[i]){ primes[nprime++]=i; if(i<=limit){ for(j=i*i;j<=MAX_SIZE;j+=i*2){ mark[j]=1; } } } } } int main(){ sieve(); int n; cin>>n; while(n--){ int x; cin>>x; cout<<primes[x-1]<<endl; } } Edited by author 26.10.2013 22:11 use modulo for a-z: (ascii_char_code + 2) % 3 + 1, Nice idea, used it and it worked perfectly. Only 60 characters of code to AC. Идея замечательная, успешно применил ее в своей программе. Удалось уложиться в 60 символов. I, found, my bug. :) I get TLE for test13,it is because that my idea is to circulate all the SG-values. Can you give me some ideas?Thank you so much. I've also using a period of 68, but WA 36 #include<cstdio> #include<algorithm> #include<iostream> #include<cmath> #include<cstring> #include<map> #include<queue> #include<stack> #include<utility> #include<cstdlib> #include<string> #include<set> #include<limits> #include<iomanip> #include<fstream> #include<sstream> #define INF 2147483647 #define LLD int #define clr(a) memset(a,0,sizeof(a)) #define reset(a) memset(a,-1,sizeof(a)) #define BD(i, j) (i >= 0 && i < N && j >= 0 && j < M) #define PRINT_VAR(X) (cout << #X << " -> " << X << endl) #define PI acos(0) #define MAX_INT 2147483647 #define SIZE 1005 #define MOD 1000000009 using namespace std; int X[] = {0, 1, 0, -1}; int Y[] = {1, 0, -1, 0}; /* right, down, lft, up */ int M, N; long long res; typedef pair<int, int> Point; int dp[SIZE]; int solve(int n) { if (dp[n] == -1) { set<int> s; s.insert(solve(n - 2)); for (int i = 2; i < n; i++) { s.insert(solve(i-2) ^ solve(n-i-1)); } dp[n] = 0; while (s.find(dp[n]) != s.end()) dp[n]++; }
return dp[n]; } int main() { int t, tc, x, y, z; int i, j, k, l, h; char ch; #ifndef ONLINE_JUDGE //freopen("input.txt", "r", stdin); #endif
reset(dp); dp[0] = 0; dp[1] = dp[2] = 1; cin >> N; cout << (solve(N % 68) ? "White" : "Black") << endl;
return 0; } I changed ``` cout << (solve(N % 68) ? "White" : "Black") << endl; ``` to ``` cout << (solve(N % (68*2)) ? "White" : "Black") << endl; ``` and it got AC Could anybody tell your solution? It asks you to find the maximal primitive root of n #include<stdio.h> int main(){ int n,sum=0,i; scanf("%d",&n);- if(n>0){ sum=(n*(n+1))/2; } else if(n<0){ sum=(n*(-1*n+1))/2; } printf("%d",sum); } Maybe for N < 0 the formula is SUM = ((2-N)*(N+1))/2 Edited by author 06.11.2017 19:47 The first term is N The last term is 1 So the average is (1+N)/2 There are (-N) terms below zero And there are two more terms They are 0 and one So there are (2-N) total terms So the sum is average by total number of terms But that should not make a difference Case "N == 0" isn't processed Edited by author 20.05.2020 08:52 Edited by author 20.05.2020 08:52 i have tried this problem several years....while preparing for contests and it's always WA and it's not at all the heardest of problems..... i made an O (n log n) alg using heaps ....as usual it's WA at test 2 could someone put some tests around??? i ageve my self some and nothing....bad could somebody explain why??????????????: 1 2 3 2 3 my result: 1: 2 4 2: 1 3 6 3: 2 5 4: 1 5: 3 6: 2 AC result: 1: 2 4 2: 1 3 6 3: 2 5 4: 1 5: 1 //5 is not even conected to 1??????? 6: 3 Edited by author 13.10.2006 04:08 Edited by author 13.10.2006 04:40 Is this input legal? It seems that the last number will always be N, or the sequence itself is not legal. It's incorrect input, you cannot find a tree that satisfies your input i have tried this problem several years....while preparing for contests and it's always WA and it's not at all the heardest of problems..... i made an O (n log n) alg using heaps ....as usual it's WA at test 2 could someone put some tests around??? i ageve my self some and nothing....bad could somebody explain why??????????????: 1 2 3 2 3 my result: 1: 2 4 2: 1 3 6 3: 2 5 4: 1 5: 3 6: 2 AC result: 1: 2 4 2: 1 3 6 3: 2 5 4: 1 5: 1 //5 is not even conected to 1??????? 6: 3 Edited by author 13.10.2006 04:08 Edited by author 13.10.2006 04:40 |
|