Общий форумHi. Any ideas what they put inside the test file to #3? 4 d cd bcd abcd 1 eabcde 1 2 Thanks, found a bug :) У меня этот тест проходит :(, но WA 3... Может кто-нибудь помочь с тестом? I have passed your test,but I still WA#3.Why? Read badwords with spaces, so: 'this is badword' not: this is badword :) changes nothing, still wrong answer Could be space trimming of right side or left side a problem... Hi. Any ideas what they put inside the test file to #3? Use dp + bitmask. I got AC in 0.015 and 1M Edited by author 14.03.2024 00:30 #include <iostream> using namespace std; int main() { double n, k1, k2, k3, pos = 2, current_pos = 2, oldsum = 0; cin >> n; cin >> k1 >> k2; while (cin >> k3) { double sum = k1 + k2 + k3; if (sum > oldsum) { oldsum = sum; pos = current_pos; } k1 = k2; k2 = k3; ++current_pos; } cout << oldsum << " " << pos; return 0; } 3 3 2 u need to think wa 10 output for "3 3 2": 1 1 2 2 8 8 6 6 1 5 5 2 8 10 10 6 3 0 5 4 9 9 10 7 3 3 4 4 21 9 7 7 12 12 14 21 21 19 18 18 12 15 14 14 19 19 20 18 11 15 15 13 17 20 20 16 11 11 13 13 17 17 16 16 no overflow, checked all cases for n \in {1, 2, 3} Listen everyone, who wants to prove the algorithm to this problem! See the solution of the problem 3 from IMO34 (International Mathematical Olympiad, year 1993). The rectangle in that problem is n*n (not m*n), but it isn't important. And the case 1*n is clear, I think. The problem statement in the problem set for IMO34 is somewhat better. Definitely worth reading. Ok, just posting this to help others understand few things here: The sequence is 1101001000100000... If you see the locations of the digit 1, you can observe that it is at location 1,2,4,7...=> ( 1 + 0 ),( 1 + 1 ),( 1 + ( 1 + 2 )),( 1+(1+2+3 )..So, it is 1+sum_of_n_digits. What we have now is below: 1 + n*( n+1 )/2 [ note that n*(n+1)/2 is the sum of first n natural numbers ]. Now, this value should be equal to the input value, say P. 1 + n*(n+1)/2 = p [ I/p P=7 => n should be 3, back track ]. 2 + n^2 + n = 2p n^2 + n = 2(p-1) n^2 + n - 2 (p-1) = 0; This is a quadratic equation in 'n'. The roots of a quadratic equation are ( -b +- sqrt( b^2 - 4ac ) )/2a -1 +- sqrt( 8p-7 ) / 2; But, for our example, if you do some analysis, if the value of 8p-7 is a perfect square, then the value at that position 'p' would be 1. Else the value would be 0. So, check for 8p-7 to be a perfect square. This is the optimal solution. Got mine accepted. BTW, if you face any difficulty at test 3, it means you have to upgrade your ints to doubles. Because 8p-7 can falll over the size of int [atleast in Java]. Thanks, ElPsyCongroo. Thanks for the hint. I tried a very similar algorithm but was still getting WA on Test 3 in Java. I finally switched over to Python, and got AC I tried hard with python but all I got was TLE, when I turn into c++ I got AC. У меня на эту задачу есть Accepted решение на Питоне, 499 мс How ( -b +- sqrt( b^2 - 4ac ) )/2a transforms into -1 +- sqrt( 8p-7 ) / 2 ? I do it like this: the n-th '1'should be here: n(n-1)/2+1.So, we judge whether the input number(x) == (n(n-1)/2+1). it could be transformed to 2*x-2 == n(n-1), and int(sqrt(2*x-2)) must be the number 'n' if 'n' exists! sorry, int(sqrt(2*x-2)) == int(sqrt(n*(n-1))) == int(n-1) if 'n' exists How can i upgrade my ints to double ? Sorry for my ignorance.I'm a newbie... vi apnar analysis deikha chudna hoia gelam, airokom chinta kamne ashe mathai Edited by author 20.07.2018 22:26 Edited by author 20.07.2018 22:26 nice Edited by author 20.07.2018 22:26 My initial approach was slightly different, but at the end, it gave the same result. Here's the sequence -> 1 10 100 1000 10000 100000 ... In that sequence, 1s are located at position -> 1, 2 ,4, 7, 11 , 16, 22 ... Look at the 11th position in the sequence. There are total (1+2+3) zeros and (1 + 1 + 1 +1) ones before the 11th 1. So the position no 11 can be written as the sum: (1+2+3) + 4 x 1 + 1. Take another position as example, say 16. Before the 16th position, there are total (1+2+3+4) zeros, and (1+1+1+1+1) ones. And so 16 can be written as, (1+ 2+3+4) + 5 x 1 + 1. Now if you generalize this observation and formulate it, you'll get : n(n+1)/2 + (n+1) x 1 + 1 = (position no containing 1) After simplification, the equation stands: n^2 + 3n + (4 - 2 x Position No) = 0 So for any INTEGER value of n, you'll get a Position No for 1 . Now think the opposite of this . If the Position No contains 1, then n will must have an Integer value. Otherwise, the Position No will contains 0. Solving that equation, you'll get: n = ( -3 +- sqrt( 9 - 4 x 1 x (4 - 2 x Position No)) ) / 2 For n to be an Integer, the determinant (9 - 4x(4 - 2 x Position No)) or (8 x Position No - 7) must be a square number. This an O(log n), because the sqrt function is O(log n) Добавьте тесты, где точки пересечения прямых очень далеко, и эти прямые почти параллельны. Моя AC программа не проходит тесты: -1000 -1000 -999 1000 0 -1000 1 999 999 -1000 1000 998 -1000 -1000 -999 1000 998 -1000 999 999 999 -1000 1000 1000 Thymus gives an error on test 53. What should I do? How do you even check what’s wrong? I enter the number 26584441929064321 and the program returns 26584441929064321, but another person on the forum wrote that this is the correct answer. What's the problem then? Please help Edited by author 08.03.2024 22:12 a , b , c = list(map(int , input().split())) y = 0 if a <= b: print(0) exit(0) while True: y+=1 if a - (a / 100 *c) > b: a-= a / 100 *c else: break print(y)
GIVE ME SOME TEST!!!!!! I STILL HAVE WA#2!!!!!!!!! [code deleted] this right? Edited by moderator 22.02.2006 00:38 var a,b,n,k1,k2:longint; begin readln(a,b,n); while n>=a do begin n:=n-a; k1:=k1+1; end; while n>=b do begin n:=n-b; k2:=k2+1; end; writeln(k1,' ',k2); end. земляк помоги решить 10 задачу или проверь 8 5 10 Answer: 0 2 Do you check if N=0?? sorry for doublepost Edited by author 11.02.2006 16:13 My answer is 0 0. Whay it does not work too? (WA#2) var a, b, n: LongInt; x,y,xo,yo,q,w: LongInt; begin Read(a, b, n); x := n div a; xo := n mod a; y := n div b; yo := n mod b; q := x * a + xo div b * b; w := y * b + yo div a * a; If q >= w then WriteLn(x, ' ', xo div b) Else WriteLn(yo div a, ' ', y); end. 47 3 49 ans: 0 16 2 3 7 ans: 2 1 It is not guaranteed that A >= B and 2 test checks this. AFAIK if you will throw error if B > A, then you will get Runtime Error on test 2. Edited by author 06.03.2024 16:54 "needs to make exactly k nano liters of the oxide in any of the test tubes" When you have k nano liters in a test tube that is not #1 the checker gives WA. My AC program was getting WA because my final test tube wasn't #1... Got WA #1 with the following output: 4 2 5 4 3 3 5 5 1 It seems correct, except for the fact the final tube is number 5, and not #1. Anyways, nice problem <3 Problem statement is annoying to read. The following shows results from K=0 to K=50 (mod 1000000007). Hope this helps. 0 0 1 1 2 2 3 3 5 5 7 7 10 10 13 13 18 18 23 23 30 30 37 37 47 47 57 57 70 70 83 83 101 101 119 119 142 142 165 165 195 195 225 225 262 262 299 299 346 346 393 В конце замечаний на русском языке исправьте "для восточной/южной" на "для восточной/западной". Спасибо (долгота) Russian statements fixed. Thanks. Think about O(N) solution, task much easier than is looks like. I use queue and got AC despite my solution probably has O(N * queue_work_complexity), not clearly O(N) #include<iostream> using namespace std; int main(){ int a,b, thief[10000],i=0; cin>>a; cin>>b; int count = 0; for (int i = 0;i<10000;i++){ thief[i] = i; // cout<<thief[i]<<" ";
} for(i=0;i<10000;i++){ //cout<<"first"<<i<<endl; if(a==thief[i]||b==thief[i+1]){ count++;
} // cout<<"thief["<<i<<"]"<<thief[i]<<"\t"<<"thief["<<i+1<<"]"<<thief[i+1]<<endl; i=i+1; //cout<<"thief"<<i<<endl;
} if(count>0) cout<<"yes"; else cout<<"no"; } This code is not very efficient. Try this code instead: #include <iostream> using namespace std; int main(){ int key1;cin>>key1; int key2;cin>>key2; if((key1%2==0) || key2%2!=0){ cout<<"yes"<<endl; } else{ cout<<"no"<<endl; } return 0; } Edited by author 01.03.2024 21:16 Edited by author 01.03.2024 21:16 What is test 3? I tried 1 (output 2) 2 (output 3) 3 (output 2) All of those are correct... Edited by author 09.05.2025 09:16 It was due to overflow. I changed a few variables to long long and it got accepted. Edited by author 25.08.2015 13:20 Edited by author 25.08.2015 13:20 Please give some additional info |
|