Show all threads Hide all threads Show all messages Hide all messages |
Hint without doubles + Python | edfearay11 | 1133. Fibonacci Sequence | 20 Dec 2024 07:04 | 1 |
Consider the fact that for any sequence $G$ with the form of fibonacci, that is: $G_{i+1} = G_i + G_{i-1}$, then $G_i = G_1 \cdot F_i + G_0 \cdot F_{i-1]$. So the problem became to solve two linear equations in integers. Prove it with induction or consider the matrix exponentiation for fibonacci. You should use Python to avoid overflow (long long isn't sufficient, at least for my implementation). Good Luck! |
If anyone gets WA19... | Hristo Nikolaev (B&W) | 1133. Fibonacci Sequence | 9 Dec 2022 03:00 | 1 |
Consider the case in which n < i, j That helped me to get AC |
Can someone explain me why's that test case is impossible? | Ivan | 1133. Fibonacci Sequence | 14 Aug 2022 02:33 | 1 |
-1000 0 0 1 1 My solution do not deal with testcases like this, yet still was accepted. Am I missing something? For those who wonder, my program gives 9079565065540428013 on this testcase lol |
On G++ we can use __int128 | Igor Parfenov | 1133. Fibonacci Sequence | 1 Aug 2022 02:14 | 1 |
If you calculate with formulas, then long long is not enough. You can use __int128. You can't read and write it, but you can cast it to and from other integer types. |
for runtime error on 10 | Abid29 | 1133. Fibonacci Sequence | 9 Mar 2021 13:08 | 1 |
intput 4 0 333 0 777 output 0 |
To Get AC test 10 on c++ | i_akash | 1133. Fibonacci Sequence | 1 Jun 2018 16:56 | 1 |
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 |
Hints for WA15 | Ade | 1133. Fibonacci Sequence | 13 Mar 2017 20:16 | 1 |
46 1836311903 -46 -1836311903 45 |
WA #2 | Vishakha Banka | 1133. Fibonacci Sequence | 22 Jan 2017 19:52 | 1 |
WA #2 Vishakha Banka 22 Jan 2017 19:52 I got wrong ans on test case 2. what is the test case? Please help. |
WA8 with formulas | Daniel Mahu | 1133. Fibonacci Sequence | 15 Oct 2016 18:47 | 2 |
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. |
Please help me Wa15, in c++ with BINARY SEARCH | Fibo | 1133. Fibonacci Sequence | 15 Sep 2016 04:39 | 6 |
Oqromnaya Spasibo Vladimir Yakovlev. You are GREAT. 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. |
Take care of your Binary Search !!!!!!! | Eazy jobb | 1133. Fibonacci Sequence | 13 Jun 2016 14:12 | 2 |
for(int m=i+2;m<=j;m++) if((m-i)%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. |
One test | [MAI] Zhigireva Alex | 1133. Fibonacci Sequence | 13 Jun 2016 14:08 | 2 |
One test [MAI] Zhigireva Alex 20 Jul 2012 18:55 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. |
Hint: AC in Python 2.7 | SRC | 1133. Fibonacci Sequence | 29 Jul 2015 15:41 | 1 |
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 |
Bugurt thread | Evgeny Shulgin | 1133. Fibonacci Sequence | 15 May 2015 01:44 | 2 |
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 |
What is TEST 2? | bluestar | 1133. Fibonacci Sequence | 26 Mar 2015 14:49 | 3 |
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? |
WA 5. WTF? | nexerd | 1133. Fibonacci Sequence | 17 Mar 2015 21:41 | 1 |
#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(j-1,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(i-1,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; } |
A simple way to correct solution | olpetOdessaONU [1 2/3] | 1133. Fibonacci Sequence | 18 Feb 2015 14:27 | 4 |
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. |
HINTs for WA15 | Erko | 1133. Fibonacci Sequence | 4 Nov 2014 22:23 | 7 |
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 |
Got Wrong Answer on Test3 | Gevorg Soghomonyan | 1133. Fibonacci Sequence | 17 Sep 2014 21:25 | 3 |
Does anyone what's the test 3????? Edited by author 25.09.2012 09:12 its if n equals to i or j |
WA15 with C++ but AC with Python | lennon310 | 1133. Fibonacci Sequence | 13 May 2014 08:43 | 1 |
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? |