you were right!!
my problem was with the log function.
my idea was almost same as the editorial except i didn’t use the periodicity part…
i observed a relation among the numbers
you were right!!
@as_max_rider Well its good that you figure it out.
hey everyone. cant i avoid TLE using this method i have done?
I am seriously facing trouble understanding that. Can anybody give me an easy explanation.
Or handily you can avoid any sort of log function - use the bit_length() function of int class.
my code https://ideone.com/nXxuep
is partially correct, is it wrong to use log2(n) for large inputs…?
Thanks in advance…!
This solution seems to give
0 for the testcase:
In general, it’s a bad idea to use floating point where an integer solution is expected (though it’s OK sometimes e.g.
sqrt when testing for primality, etc). People have come up with testcases where the use of
log gives the wrong answer for FIBEASY - see e.g. here and the post linked from that post.
Why website shows runtime error of problem code fibeasy?
int T, N, j;
int first = 0,second = 1;
f = first;
f = second;
f[i] = first + second;
first = second;
second = f[i];
f[i] = f[i]%10;
f[j] = f[i];
N = N/2;
Can anybody review this solution of mine and tell me why is it showing TLE and how can i make it more efficient?
can anyone tell why my code (SEE THIS) is giving partially correct for subtask1 and wrong answer for subtask2
So we should basically know that fibonacci no.s mod 10 are periodic with period 60. So vague, isn’t it?
Or do they expect us to figure it out?
Well I read about Pisano period, its written that its not possible to manually calculate it for a given integer. (here)
Should we print the values and check ? Sounds very tedious and counterintuitive.
I can’t remember what I did - I either printed out the values, spotted the pattern and deduced why; or the other way around
The logic behind it is fairly simple:
Thanks a lot. U explained it in a nice way
Can any body know that Fibonacci numbers mod 10 is periodic when they encounter the problem for the first time ?
I’m getting WA in subtask 2. I’m not getting what is wrong.
Here is my code
Any help would be appreciated.