Общий форумTwo Complex numbers are equivalent if they have the same moduli and there argument differ by a multiple of 2pi.how best can you solve this without encountering irrational numbers especially when you are dealing with nth root. Edited by author 15.06.2013 20:16 Yes, there's exists solution only in integer numbers for this problem. Edited by author 08.07.2018 15:42 1) 4 4 1 2 9 15 1 4 0 8 2 3 20 30 3 1 31 0 1 4 9 30 -> 4 1 3 4 2 2) 2 3 1 2 0 5 1 1 110 80 1 1 90 0 1 2 100 6 -> 3 2 3 1 3) 3 6 1 2 50 55 2 1 55 40 1 2 0 1 1 3 41 80 3 2 80 12 2 1 15 0 1 2 49 7 -> 6 1 2 4 5 6 3 #include <bits/stdc++.h> using namespace std ; #define DEBUG(x) cout << '>' << #x << ':' << x << endl; #define mem(x,val) memset((x),(val),sizeof(x)) #define all(x) x.begin(),x.end() #define pb push_back #define mp make_pair #define PI acos(-1.0) const int INF = 1 << 29 ; typedef long long ll ; int N(int n , int k ) { if(n == 1) return k<10?1:0 ; int sum = 0 ; for(int i = 0 ;i<= 9 && i<=k ; i++){ sum+=N(n-1 , k-i) ; } return sum ; } int main() { int n ,sum = 0 , temp ; scanf("%d" ,&n) ; n/= 2 ;
for(int i = 0 ; i<=n*9 ;i++){ temp = N(n,i) ; sum+=(temp*temp) ; } printf("%d\n" , sum) ; return 0 ; } I have thought about something like lazy calculations model #include<iostream> #include <iomanip> #include<vector> int main(){ long long num; std::vector<double> v; int count=0; while(std::cin>>num){ if(num==0){ v.push_back(num); } else{ int i=0; double n=num/10; while(i<10000){ n=n-(n*n-num)/(2*n); i++; } v.push_back(n); }
} for(int i=v.size()-1;i>=0;i--) std::cout<<std::fixed<<std::setprecision(4)<<v[i]<<std::endl; return 0; } Suppose you have no WA. Then you might have 15000+ square roots by 10000 iterations each (If pay attention there are maximum 256KB of numbers) TLE for sure Yup. I just realized it. But I think it converges to 4 decimal places much, much before 10000 iterations (say, like 300-400). Thanks for the help :) I was barely able to pass the TL by using the segment tree. That part probably works OK, but what causes troubles is the way I locate the array index by given content value (i.e. we want do delete 8, so I search for 8's index and replace it with 0). For that purpose I was using map from STL and wasn't able to come up with anything better (except some hash-like storage). What did you use for that purpose or could you avoid such situation at all? Thanks. I solved by exactly the same algorithm, but got TLE 16-21. Then I just changed my cin to scanf and got AC for 0.218 Try ios::sync_with_stdio (false) . Report was it success or not. I am interested how useful is ios::sync_with_stdio(false) . Yes it does help. My solution (sqrt) was TLE 17. after this line it is AC 0.421. Just put this into main as the first line. thanks for the suggestion, I was too lazy to use scanf:) dont forget though that if you use this, then you cannot use printf and scanf in the same program with cin It's a complete disaster! I just don't get it. 1) Quote: "Exactly 1 mm of precipitations fall down on the pitch each minute" Another quote: "You should output the average amount of precipitations (in millimeters) falling on the pitch in a minute." So the reasonable question is: "Why the answer is just the area of the pitch without a small piece??" It shoud be less than one millimeter! Ammount of precipitations is the height of the water column that arises from the surface in a particular period of time. Hence under the umbrellas the ammount equals to zero. And according to the statement the answer is (1 - area_covered_with_umbrellas / area_of_the_pitch). 2) Quote: "All the water that has fallen on an umbrella streams down along the shortest way on the hemisphere." So what? Does it mean that the water from the umbrella falls back on the pitch without changing the answer? Or, may be, it changes somehow the ammount of precipitations in the area near the umbrella... And if the umbrella is on the border of the pitch, than what ammount of water falls outside the pitch - area of spherical sector or area of its projection or area of spherical sector minus area of the layer falling out of the pitch? BTW None of these variants didn't produce the answer given in the sample output. I'd appreciate any information you could give me to remove an ambiguity. 1)HINT: за счёт зонтов осадков может выпасть больше. 2)"Вся вода попавшая на зонт, стекает по радиусам зонта от центра к краям" и затем падает вертикально вниз. I got WA4. Then i sorted answer by <length, int, int> and got AC. [code deleted] Edited by moderator 02.01.2020 18:17 cout<<"enter a number for the lines "<<endl; Surely that is wrong I was trying to remove from the set first non-zero count money unit that is NOT LESS than ticket But actually the task asks to remove just the FIRST non-zero count money unit If act according to the former strategy you will receive WA20. #include <iostream> #include <vector> using namespace std; string per(int x) { int k(0),b(x); string m; if (x<10) {m+=char(x+'0');return m;} while(x!=0) { x=x/10; k++; } x=b; b=k; string s; while(k>0) { s+=char((x%10)+'0'); x=(x-x%10)/10; k--; } for(int i=0;i<b;i++) m+=s[b-i-1]; return m; } int main() { int n,m,i,j,p,t(1); char s[80]; string Y; vector<int> v; vector<int> w; v.reserve(1); w.reserve(1); scanf("%d",&n); scanf("%d",&m); for(int d=0;d<n;d++) { scanf("%s",s); if(s[0]=='l') { scanf("%d%d",&i,&j); if(j>m) continue; if(t<i) continue; v.push_back(j);w.push_back(i); p=w.size(); for(int x=0;x<p;x++) if(w[x]==i && v[x]<0) {v.erase(v.begin()+x);w.erase(w.begin()+x);} } if(s[0]=='r'&& s[1]=='o') { scanf("%d",&i); p=w.size()-1; while(v[p]<0 || w[p]!=i) p--; v[p]-=1000000;} if(s[0]=='c'&& s[1]=='h') { scanf("%d",&i); if(w.size()>0) { for(int x=w.size()-1;x>=0;x--) if(w[x]==i && v[x]>0) {Y+=per(v[x]);if(d!=n-1)Y+="\n";break;} else if (x==0) {Y+="basic";if(d!=n-1)Y+="\n";} } else {Y+="basic";if(d!=n-1) Y+="\n";} } if(s[0]=='r'&& s[1]=='e') { scanf("%d",&i); p=0; while(v[p]>0 || w[p]!=i) { p++; if(p>w.size()-1) break; } if(p>=0) v[p]+=1000000; } if(s[0]=='c'&& s[1]=='l') { if(t<i) continue; t++; scanf("%d",&i); p=w.size(); for(int x=0;x<p;x++) if(w[x]==i) {v.push_back(v[x]);w.push_back(t);} } } cout<<Y; } I can't make up any new tests. Everything, I tried, works. If you have some ideas, please, help Edited by author 01.08.2017 15:26 Edited by author 01.08.2017 15:28 The problem is connected with recoil #include <iostream> #include <string> #include <map> #include <vector> #include <cctype> #include <algorithm> #include <math.h> #include <iostream> using namespace std; int main() { int N = 0, k = 0; string s; getline (cin, s); char name; for (auto i = 0; i < (int)s.length(); i++) { name = s[i]; if (name == 'a' || name == 'd' || name == 'g' || name == 'j' || name == 'm' || name == 'p' || name == 's' || name == 'v' || name == 'y' || name == '.' || name == ' ') { k = 1; N += k; } if (name == 'b' || name == 'e' || name == 'h' || name == 'k' || name == 'n' || name == 'k' || name == 't' || name == 'w' || name == 'z' || name == ',') { k = 2; N += k; } if (name == 'c' || name == 'f' || name == 'i' || name == 'l' || name == 'o' || name == 'r' || name == 'u' || name == 'x' || name == '!') { k = 3; N += k; } } cout << N; return 0; } You forgot 'q' in the second if 2 1 3 1 4 3 5 1 6 4 7 2 8 6 9 8 10 7 ans: 8 or 1 The problem is very simple. It is clear from the first glance what is going on. The coding is trivial. The math part is trivial. And... for some reason it is almost impossible to get AC from the first try. Можно просто перебирать ответ наименьшего возможного, двойки, пока не найдем нужное значение. Для данного количества жителей можно за log этого количества по времени найти требуемое количество кондукторов. Здесь пишут про int_64, про "не использовать double" и "использовать epsilon=1e-9". В моём варианте такое не нужно Хватило int_32 и double. Никакого epsilon, сравнения непосредственно оператором <=. #include <iostream> #include <string> #include <map> #include <vector> #include <cctype> #include <algorithm> #include <math.h> #include <iostream> using namespace std; int main() { int N, ch; int h = 1; int max = 0; int second_max = 0; cin >> N; vector <int> m(N); vector<int> v(N); vector<int> k; for (int i = 0; i < N; i++) { cin >> ch; v[i] = ch; } for(int i = 1; i < N; i++) { if(v[i] > max) { second_max = max; max = v[i]; } else { if (v[i] > second_max) { second_max = v[i]; } } } for (int i = 0; i < N; i++) { if (v[i] != max && v[i] != second_max && v[i] != v[0]) { k.push_back(v[i]); } } sort(begin(k), end(k)); m[0] = v[0]; m[1] = second_max; m[N - 1] = max; for (int i = 2; i < N-1; i++) { m[i] = k[k.size() - h]; h++; } for (auto j = 0; j < N; j++) { for (auto i = 0; i < N; i++) { if(m[j] == v[i]) { cout << i + 1 << " "; i = N; } } } return 0; } Please explain your solution Можно сдать тернарным поиском на Python 3.4 с параметрами : количество итераций -- 100 максимальное А и максимальное B -- 10**18 My AC program had TL when we have this test (with a log of garbage, but still acceptable by task conditions) 131 393 struct used .int .int struct aa .int .int struct ab .aa .aa struct ac .ab .ab // many lines...... struct ew .ev .ev struct ex .ew .ew struct ey .ex .ex struct ez .ey .ey 000000010000000200000003 Can you add this? Link to full test - https://gist.github.com/Izaron/1a4fd5894f45fafc2d6d46f0f8d81ce3I solved this problem( 0.015 sec) but My algo is heuristic. Why this problem is geometric? Or how can we use geometry in this task to reduce the search? I think there might be as well a mistake in tags. To me, this problem reminds of http://acm.timus.ru/problem.aspx?space=1&num=1326 with minor differences: 1) cities = bottle taps 2) N <= 30 instead of N <= 20; 3) city's "group" is a list of cities hit when bombing this one. Insert this magic line before the code #pragma comment(linker, "/STACK:36777216") And it works! That is not magic That line sets stack size to 16 MB And you forgot the most important thing The code works ONLY with Microsoft Visual C++ |
|