code is working just fine on laptop but online it repeatedly says time limit exceeded…How can I solve this problem??
Compute F(N) error
Don’t use a loop. Try to make some formula.
N is very large you can’t iterate.
2 Likes
Sir tried making formula and code now ran again fine on laptop but online it shows test case failed(wrong answer)
It’s n/2 for even case and (n-1)/2 - n for odd case
Its working for me , try this
https://ide.codingblocks.com/#/s/18284
1 Like
Thanks the main code i was missing was long long n.
can you please post the question link.
thank you