Spoj GSS1 problem

Thanks a lot @shraeyas

1 Like

Shouldn’t the answers be 10??

1 Like

@kodeerder Since f (x) = f (x-1) + f (x+1) so that =》f (x+1) = f (x) - f (x-1), use the concept of generating fibonacci numbers to solve it for f (x+1)

2 Likes

Exactly, it should be 10 :slight_smile:

Sorry my bad

1 Like

Thank you @meooow i am now very much clear this Thank you once again

1 Like

Thank you @neilit1992 .your photos helped a lot Thank you once again

Can u tell now what’s wrong - 126Z36 - Online IDE & Debugging Tool - Ideone.com

1 Like

@anno Mark it as accepted answer :smiley: and no problem codechef discuss is meant to help… PS i too faced problem while solving this the 1st time.

In line number 27 you can use x <<n than manually multiplying using while loop…

1 Like

Tried, but it still gives TLE

1 Like

No it is passing with 0.04 seconds.

1 Like

@neilit1992 does that make any difference?

1 Like

Can’t see your solution on spoj. You need to give ideone or pastebin link.

1 Like

Oh ,sorry…I forgot

I will…let me see to it.

1 Like

@mathecodician please show your working code.

1 Like
1 Like

What changes did you make?

Just added the input. I wasn’t giving any input.

@mathecodician using vector for R1 and R2 is slowing you down. Use arrays instead and you will get AC. Also your INF*INF is actually overflowing which is not a problem here, but it may be an issue is some other problem so be careful about that.

1 Like

You’re welcome :slight_smile: