Use if(c> 8000000000LL  c< 8000000000LL) break ; this line in BInary search... code : [deleted] Edited by author 01.06.2018 17:02 Edited by moderator 20.11.2019 22:45 46 1836311903 46 1836311903 45 I got wrong ans on test case 2. what is the test case? Please help. I used the formulas with phi and solved a system of 2 equations to get the coefficients, in python using floats. Any hint why I get WA8? all tests on the forum work. I eventually got AC by trying out several values around the integer the math formula gave and checking each against given initial values. Try this test: 1 1 3 2 2 Oqromnaya Spasibo Vladimir Yakovlev. You are GREAT. What should it give you? Regarding 1 1 3 2 2, it means that first element is 1, and third element is 2. Since first+second=third, second is obviously 1. And that is the answer. Howevewer, mine solution is okay with this test and still WA15 for now. for(int m=i+2;m<=j;m++) if((mi)%2==1) { t2+=t1; if(t2<8000000000LL(t2>8000000000LL))//Look at this line. break; } else { t1+=t2; if(t1<8000000000LL(t1>8000000000LL))//Look at this line. break; }  Sorry for my bad English You can also do equation system (IDK if it's the correct name). You can make two equations, with two incognitas. It can be solved because you have the same amount of equations and incognitas. Be careful, it's easier with java big integer rather than C++ long long or long double. F1 = 1 F4 = 4 what numbers are F2 and F3? F2 = F1+F0 F3 = 2*F1+F0 F4 = 3*F1+2*F0 F0 == 0.5??? anzhig@inbox.ru Edited by author 20.07.2012 18:56 In the problem says: "is an infinite sequence of integers" So, this is an invalid sequence. The fastest way is to use matrix exponentiation and it is quite simple to understand. The algorithm is O(log n), yes it is that fast!. I got AC with Python 2.7 with 0.046s. Python has an added advantage for this problem since its Integer type can be as big as the RAM of the device being used. With c++ you can still get answers fast, using matrix exponentiation, but the answers are not precise enough, and leads to WA. Edited by author 29.07.2015 15:42 I killed a lot of time writing the solution in C++, Python, Java. Java gives AC with BigInteger _ It is NOT solvable with int64 It is not solvable BY YOU with int64 Got WA2. please respond. Cleared the fault. But now WA 16. Cleared the fault. But now WA 16. Using C++. Is it a problem due to using long double? #include <iostream> #include <conio.h> using namespace std; void find(int j, int i, int &k1,int &k2) { if (j==i+1) return; else { int buf = k1; k1 = k1 + k2; k2 = buf; find(j1,i,k1,k2); } } int main() { long long Fi, Fj, f1,f2, f3; int i,j,n; cin>>i>>Fi>>j>>Fj>>n; if (j==n) {cout<<Fj<<endl; return 0;} if (i==n) {cout<<Fi<<endl; return 0;} if (i<j) { int buf = i; i = j; j = buf; buf = Fi; Fi = Fj; Fj = buf; } int k1 = 1, k2 = 1; f1 = Fj; if (i!=j+1) { find(i1,j,k1,k2); f2 = (Fi  k2*Fj)/k1; } else f2 = Fi;
int lim; if (j<0) lim = n  j 1; else if (j == 0 ) lim = n; else lim = n  j +1; for (int count = j +1; count < lim; count++) { f3 = f1 + f2; f1 = f2; f2 = f3; } cout<<f3<<endl; return 0; } If you use formula in C++, you don't need the long arithmetics. Use long double and you'll get AC. i used long double, 2 4 6 29 1000 but my answer is 6.00693e+208, is it correct or not? you should turn off siencetific notation My approach goes like this: lets choose a big random prime P > 10^16, and calculate F_(i+1)%P. I tried solve this problem 6 times and 3 of their are WA15, This WA is expects when uses binsearch, when I replaced type of numbers from long to BigInteger in java, I got AC, in this 15' test intermediate(промежуточные) numbers bigger than 2000000000 or lower than 2000000000, that is why we have wrong answers )) Good luck! Edited by author 27.01.2009 21:59 I use binsearch and long long in C++, all is ok. by finding value with BS you can take for example 10^9 and if the previous value is 10^9 then you get the following sequence 10^9, 10^9, 2*10^9, 3*10^9, 5*10^9, and so on. by overflowing the integer and long types the answer is wrong I used next hint: for (.........) { .... if (fib[i] > 2*10^9) fib[i] = 2*10^9 +1; if (fib[i] < 2*10^9) fib[i] = 2*10^9 1; } Edited by author 01.06.2010 16:57 Edited by author 01.06.2010 16:57 Thank you very much, it is just the reason why I got a WA at #15. I tried what you say, but also WA15. I can't understand why?? Well,that was worse....Thanks for hint Does anyone what's the test 3????? Edited by author 25.09.2012 09:12 its if n equals to i or j I used C++11 with long long type, still cannot pass #15. After changing my code to python 2.7, I got the AC. Since the input range is [2000000000,2000000000], long long type should not suffer from overflow. Then what's the reason of WA 15? 1000 0 0 1 1 the real output is 0. 1000 1 0 2 1 the answer 4.34665576869374564E+0208 1000 1 0 2 1 the answer 4.34665576869374564E+0208
1000 1 0 2 1 the answer 4.34665576869374564E+0208
the real answer is 1 1000 0 0 1 1 the real answer is 2 1000 1 0 2 1 the answer 1 wrong see 0 1 2 3 4 5 6 7 ... 1000 2 1 1 0 1 1 2 3 ... big integer value i think it is incorrect test, all value integer(..sequence of integer numbers...) It solved my problem 0 1 1 1 0 after this test i pass 9 test and get ac 3 5 1 4 1 answear: 4 Edited by author 08.11.2013 21:24 i use binsearch and have wa 15.. i found this test 1 1 5 1 2 what's answer? is this test correct? My AC solution replies 1. I don't know if this test is correct as I solved this problem loooong ago. this test is incorrect because answer for it is (1/3), it's not integer number 1st elem  1 2nd elem  1/3 3rd elem  2/3 4th elem  1/3 5th elem  1 Edited by author 01.11.2008 04:06 i use binsearch and have wa 15.. any hints plz About this test {1 1 5 1 2} case the answer is also 0. The sequence is {1 0 1 0 1} Edited by author 01.04.2011 15:39 It's wrong. If f[2]=0, the sequence is {1 0 1 1 2}. How to avoid WA 15 While calculating f[n] during another iteration of binary search, every time check if f[i] is out of [2*10^9, 2*10^9]. If it is, immediately break calculation cycle, update binary search interval and start another its iteration. I used formula and a C++ type long long, but still somehow managed to get WA 15. Even though i got around it by calculating in Zp (where p is a prime number bigger than 4 * 10^9), it still blows up my mind how it's possible to overflow long long without violating the statement. Such a tricky test, i'd like to see it. Some tests: test: 36 1680987685 37 1439530908 1 ans: 12 test: 42 1330344015 38 1330344015 30 ans: 4131543 test: 459 0 245 0 999 ans: 0 Edited by author 05.11.2013 18:43 Edited by author 05.11.2013 18:47 It’s Runtime error in case#10 who can tell me Why? 第10组Re为什么？ 
