http://www.codechef.com/viewsolution/5964055
Code is here please let me know why is the system generating a wrong answer for my code :)And here is the link to the problem http://www.codechef.com/problems/AMIFIB

You are generating fibonacci numbers only upto 100 and 100 th fibonacci number is 354224848179261915075. It’s given that number of digits in A is <=100, so fibonacci numbers more than 100 can also be your input. Thus, your code is failing on many test cases.

There are many approaches to solve the problem, refer editorial here.
You may use the fact that if 5 * n * n + 4 or 5 * n * n - 4 is a perfect square number, then n is a fibonacci number. Or generate all fibonacci numbers upto 6666 and insert them in a set and check, my solution based on this.

Although the conceptually correct solution I feel is this: Take two initial strings 0 and 1, add the two strings, and insert this string also in a vector. that is generate all possible fibonacci numbers till the size of string is <=1000, add the last two and find a new one. My solution based on this.

No, what I mean is lets say x’th fibonacci number is there such that f[x] contains 1000 digits. This is not same as 1000th fibonacci number. Read carefully, it says “(number of digits in A)<=1000” not “A<=1000”!!

can u let me know where i need to make the change in my code

@codeius See the edit above…

Thank you appreciate it:)

Happy to help… Close the thread after it satisfies you and accepting the answer…