Show all threads Hide all threads Show all messages Hide all messages |
what is wa 3? here is my code! | john | 1149. Sinus Dances | 23 Jun 2019 02:44 | 1 |
#include<iostream> using namespace std; void sin (int n,int i) { if(i==n+1) return ; else { if(i==1) { cout<<"sin("<<i; sin(n,i+1); } else if(i%2==1) { cout<<"+sin("<<i; sin(n,i+1); } else { cout<<"-sin("<<i; sin(n,i+1); } cout<<")"; } } void sol( int n,int i) { if(i==n) return; if(i==1) for(int i=1;i<n;i++) cout<<'('; sin(i,1); cout<<'+'<<n-i+1<<')'; sol(n,i+1); if(i==1) { sin(n,1); cout<<"+1"; } } int main () { int n; cin>>n; sol(n,1); } |
Algo | Baurzhan | 1748. The Most Complex Number | 22 Jun 2019 21:25 | 9 |
Algo Baurzhan 26 Jan 2010 11:48 Can somebody tell me how solve this problem? what is test19? maybe some wrong in test19 It can be solved using backtracking :) Re: Algo Igor Mihajlovic 3 Apr 2010 15:39 can anyone tell me what algo for this problem Re: Algo Artem Khizha [DNU] 28 Jul 2010 17:25 > can anyone tell me what algo for this problem I can, though my approach wasn't so easy. I used precalculations. My way is to generate all pairs (N, P), where P = 1, 2, ... - complexity of number and N - such minimal number, that has exactly P divisors. How to do this with such large inputs? Solve another problem: recover N, if you know P. I used backtrack there, but still I'm wondering whether there is a more beautiful way. First I wrote a recursive function that tries all v=2^a * 3^b * 5^c * 7^d * 11^e * ... with a>=b>=c>=... It generates +- a million possibilities and takes around 300 ms for each case. So I got TLE with 100 cases. Then I wrote code that reads all the n values and sort them. Then I call the recursive function with 10^18. I added a binary search to it that finds the smallest n greater or equal to v and update the best result for it. When the recursive function returns, I update the results for the larger values of n with the smaller results. And then I output the results in the same order as the input. All in less that 50 lines of C++. Re: Algo Keshav Sharma 22 Jun 2019 21:25 I think u can safely assume that that there is no number with power>10 so 10>=a>=b>=c>=d... and now I think u will get AC without doing anything else. Plus small small optimisation.. like breaking at a point if current no. > query(which is obvious to do so) and other such small small optimisation will do. Other thing is to check if ur current no. doesnt exceed the long long range (u can only check by using log()...) Re: Algo Timur_Bekibaev 31 Jan 2010 21:14 Баур, эта задача решатся "в лоб" Re: Algo SamGTU7_Kareva Nadezhda Vladimirovna 12 Jun 2013 23:56 |
If you WA#5 using hashing... | Myrcella | 1354. Palindrome. Again Palindrome | 22 Jun 2019 18:41 | 1 |
It may be caused by conflicts... (Sorry for my poor English |
WA on test 4 | abid1729 | 1079. Maximum | 22 Jun 2019 13:45 | 1 |
what is test 4. plz help me. my code is below #include<bits/stdc++.h> using namespace std; int main() { long n=1000,i,k; long long a[100000]; a[0]=0,a[1]=1; for(i=2;i<n;i=i+2){ k=i/2; a[i]=a[k],a[i+1]=a[k]+a[k+1]; } cin>>n; while(n){ cout<<*max_element(a,a+n+1)<<endl; cin>>n; } } Edited by author 22.06.2019 13:46 |
not simple AC 0.001s and 130 kb | kronos (RGATA team "friends" | 1079. Maximum | 22 Jun 2019 13:35 | 3 |
#include <iostream> int n,x; int a[10]; int i,t; int _max(int s1,int s2,int x) { if (x==n) return s1+s2; else { int t1,t2; if (x*2-1<=n) t1 = _max(s1,s2+s1,x*2-1); else t1 = 0; if (x*2+1<=n) t2 = _max(s1+s2,s2,x*2+1); else t2 = 0; if ((t1==t2)&&(t2==0)) return s1+s2; else return t1>t2?t1:t2; } } int main() { std::cin >> n; i = 0; while (n){ if (n==2) a[i] = 1; else if (n==1) a[i] = 1; else if (n==0) a[i] = 0; else a[i] = _max(1,1,3); std::cin >> n; i++; } for (n = 0;n<i;n++) std::cout << a[n] << "\n";
return 0; } #include <iostream> #include <algorithm> using namespace std; int main() { unsigned int i, v[100000]; v[0] = 0; v[1] = 1; for(i=2;i<100000;i++){ if(i%2==0) v[i] = v[i/2]; else v[i] = v[(i-1)/2] + v[(i-1)/2+1]; } unsigned int n; while(cin >> n){ if(n!=0) cout << *max_element(v, v+n+1) << endl; } return 0; } /* its not accepted. whats wrong with it?? WA on test 4 */ #include<bits/stdc++.h> using namespace std; int main() { long n=1000,i,k; long long a[100000]; a[0]=0,a[1]=1; for(i=2;i<n;i=i+2){ k=i/2; a[i]=a[k],a[i+1]=a[k]+a[k+1]; } cin>>n; while(n){ cout<<*max_element(a,a+n+1)<<endl; cin>>n; } } Edited by author 22.06.2019 13:37 Edited by author 22.06.2019 13:37 Edited by author 22.06.2019 13:39 |
no upper limit on k | Baz | 1109. Conference | 22 Jun 2019 11:58 | 2 |
Since my solution got AC, there IS a limit on k... or the tests are too weak. If the pairs are all different, there will be at most M*N different pairs.(but it doesn't say it...) |
Manacher Algorithm! | GastonFontenla | 1297. Palindrome | 21 Jun 2019 11:44 | 2 |
Hi! I'm just amazed about this algorithm! My previous O(N^3) implementation take 0.624 and 508 KB with my best efforts to reduce runtime. When I submitted the Manacher's one, the runtime dropped down to 0.015 and 2376 KB!! Just google it. It's a very easy and efficient O(N) algorithm. That's all you need to solve this problem. No more than 30 lines of code. Do u give me your implemented solution? |
Please tell me the possible outputs for n = 1-8 and k = 10 | Darwesh | 1009. K-based Numbers | 20 Jun 2019 17:58 | 3 |
Can anyone please tell me in tabular form what is are the values of answers for the above values. My algorithm is almost right and it is calculating accurately as far as I know but it is always responding No on test # 2. Please help!!! I am stuck and dissappointed.... :( 1 10 -> 9 2 10 -> 90 3 10 -> 891 4 10 -> 8829 5 10 -> 87480 6 10 -> 866781 7 10 -> 8588349 8 10 -> 85096170 ... 88 10 -> 4073204239463162109734811048211023806979858806092557057802513502380259034152215057201989 how for k=3 it should be 90 |
Give me example plz | Dias_97 | 1009. K-based Numbers | 20 Jun 2019 17:37 | 4 |
input 3 5 output : 96 input 10 2 output: 89 Edited by author 14.04.2019 17:30 Edited by author 14.04.2019 17:36 |
WA#18 | Oleg1209 | 1436. Billboard | 20 Jun 2019 16:21 | 2 |
WA#18 Oleg1209 12 Oct 2015 13:09 What is the test 18? I really don't understand it... I wrote solution with ternary search, and I think that there is problem with accuracy of calculations. Have anybody this problem? P.S. Sorry for my bad english :) You should find number extremum of function. Spoiler: It isn't true, that there is only one. Edited by author 20.06.2019 16:21 |
1001. Reverse Root | Suraj Sharma | 1001. Reverse Root | 20 Jun 2019 11:03 | 1 |
The following code is failing the test case 3, I have used linked-list to store the data in as a stack. Below is the code for reference, can you tell me where I am going wrong. Thank you. #include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<math.h> #include<assert.h> typedef unsigned long long _ull; typedef unsigned int _uint; typedef struct _link_list { _ull _number; struct _link_list*_next; } _list; void _makenode(_list**,_ull); void _insertnode(_list**,_list*); int main(int argc,const char*argv[]) { _ull _val; _list *_head,*_temp; _head = _temp = NULL; while(true) { fscanf(stdin,"%lld",&_val); assert(_val>=0); if(feof(stdin)) break; _makenode(&_head,_val); } while(_head) { _temp = _head; fprintf(stdout,"%0.4lf\n",sqrt(_head->_number)); _head = (_head->_next); free(_temp); } return 0; } void _makenode(_list**_ptr,_ull _data) { _list*_node = malloc(sizeof(_list)); (_node->_number) = _data; (_node->_next) = NULL; _insertnode(_ptr,_node); } void _insertnode(_list**_ptr,_list*_node) { if(!(*_ptr)) (*_ptr) = _node; else { (_node->_next) = (*_ptr); (*_ptr) = _node; } } |
Random Test Cases | Aditya Singh | 1138. Integer Percentage | 19 Jun 2019 08:04 | 2 |
Try testcases 12 11 1 12 10 2 100 7 7 20 7 2 1000 1 26 10000 1 37 10000 13 25 100 25 8 |
Can you explain this problem? | bad dream | 1964. Chinese Dialects | 18 Jun 2019 18:10 | 1 |
Can you please explain what this problem is asking? Input: 10 2 8 8 Output: 6 Input: 10 3 8 8 8 Output: 4 Can you explain how the output is changing? What's the logic/intuition behind this? Please explain in details. |
Help me! Please WA_7 | Jica | 1837. Isenbaev's Number | 17 Jun 2019 13:09 | 4 |
___Test 13 Fominykh Isenbaev BBB BBB CCC AAA Ayzenshteyn Oparin Samsonov Ayzenshteyn Chevdar Samsonov Dublennykh Fominykh Ivankov Burmistrov Dublennykh Kurpilyanskiy Cormen Leiserson Rivest Oparin AA AAA Isenbaev Oparin Toropov AA DD PP PP QQ RR RR SS TT TT Toropov Oparin ____correct answer: AA 2 AAA 2 Ayzenshteyn 2 BBB 1 Burmistrov 3 CCC 2 Chevdar 3 Cormen undefined DD 3 Dublennykh 2 Fominykh 1 Isenbaev 0 Ivankov 2 Kurpilyanskiy 3 Leiserson undefined Oparin 1 PP 3 QQ 4 RR 3 Rivest undefined SS 3 Samsonov 2 TT 2 Toropov 1 Thank you very much - I had WA7 and this test helped me very much. I realized that some of the numbers on my output were higher (I didn't take the shortest path in the graph). You need to take the shortest path and not the first path found. I have correct answers but still cannot pass test 7 |
Test #1 runtime error | roman velichkin | 1837. Isenbaev's Number | 17 Jun 2019 13:00 | 2 |
[code deleted] Edited by moderator 19.11.2019 23:08 problem was caused by comments, removed them and everything worked |
Why wrong(C++) (incorrect input)? | Ilya | 2100. Wedding Dinner | 16 Jun 2019 18:07 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int n,i,k=2; string s; cin>>n;
for (i=1;i<=n;++i) { getline(cin,s); if (s.find("+")!=string::npos) k+=2;
else ++k; }
if (k==13) ++k;
cout<<k*100;
return 0; } Edited by author 16.06.2019 18:08 Edited by author 16.06.2019 18:08 |
WA11 | 👨💻tproger👨💻[GTGU] | 1707. Hypnotoad's Secret | 14 Jun 2019 23:31 | 2 |
WA11 👨💻tproger👨💻[GTGU] 14 Jun 2019 14:36 Is it special test? I have no idea, what is wrong with my implementation. Re: WA11 👨💻tproger👨💻[GTGU] 14 Jun 2019 23:31 Yes, it is. It is the first (or may be not) test with negative delta's (Δs, Δt, and so on). |
I need help!! anyone | Egor | 1030. Titanic | 14 Jun 2019 22:54 | 2 |
Hello! I`ve got a code, equations must be right, but the result is different from sample. I don`t know what the problem is. Please, help!! My result is 45,28, whereas the sample`s one is 52,04. static void Main(string[] args) { const double D = 6875; const double pi = 3.1415926535897932384626433; string trash; char[] separators = new[] { ' ', '^', '"', '\''}; /* double shipx, shipy, shipz, icex, icey, icez; */ for (int i = 0; i < 3; i++) trash = Console.ReadLine(); var shipLat = Console.ReadLine().Split(separators); var shipLong = Console.ReadLine().Split(separators); trash = Console.ReadLine(); var iceLat = Console.ReadLine().Split(separators); var iceLong = Console.ReadLine().Split(separators); trash = Console.ReadLine(); double phi1 = (int.Parse(shipLat[0]) + (int.Parse(shipLat[1]) + int.Parse(shipLat[2]) / 60) / 60) * (pi / 180); double phi2 = (int.Parse(shipLong[1]) + (int.Parse(shipLong[2]) + int.Parse(shipLong[3]) / 60) / 60) * (pi / 180); if (shipLat[3] == "SL") phi1 = -phi1; if (shipLong[4] == "WL") phi2 = -phi2; double L1 = (int.Parse(iceLat[0]) + (int.Parse(iceLat[1]) + int.Parse(iceLat[2]) / 60)/60) * (pi / 180); double L2 = (int.Parse(iceLong[1]) + (int.Parse(iceLong[2]) + int.Parse(iceLong[3]) / 60)/60) * (pi / 180); if (iceLat[3] == "SL") L1 = -L1; if (iceLong[4] == "WL") L2 = -L2; double ans = Math.Acos(Math.Sin(phi1) * Math.Sin(L1) + Math.Cos(phi1) * Math.Cos(L1) * Math.Cos(L2-phi2)); double dist = ans * D/2; Console.Write("The distance to the iceberg: "); Console.WriteLine("{0:0.00}", dist); if (100.00 - dist > 0.005) Console.WriteLine("DANGER!"); } The problem is solved. It`s impossible to have the right answer with INT parsing. You need to use double. |
Don't be afraid to use string | Skeef79 | 1102. Strange Dialog | 13 Jun 2019 20:21 | 1 |
I just cin every string and then solve using it. 0.156 accepted |
Is it a "Nim"-game??? | enick | 1087. The Time to Take Stones | 13 Jun 2019 16:59 | 3 |
|