http://www.codechef.com/problems/AMIFIB
The following code is working perfect on my Dev C++ interface, but Codechef gives WA.
include<iostream>
using namespace std;
int fibonacciCheck(int n)
{
int c;
int a=0;
int b=1;
c=a+b;
while(c<n)
{
a=b;
b=c;
c=a+b;
}
if(c==n || n==0)
return 1;
else
return 0;
}
int main()
{
int t;
int a;
cin>>t;
while(t>0){
cin>>a;
if(fibonacciCheck(a))
cout<<"Yes";
else
cout<<"No";
t--;
}
return 0;
}