Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

WA in Fibonacci Number

$
0
0

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;

}


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>