标签:algorithm
3 2 3 5 2 3 6 2 2 110
Yes No YesHintFor the third test case, the new Fibonacci sequence is: 2, 2, 4, 6, 10, 16, 26, 42, 68, 110…
//0ms
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
long long a[50];
int main()
{
int t;
long long c;
scanf("%d",&t);
while(t--)
{
scanf("%I64d%I64d%I64d",&a[0],&a[1],&c);
if(a[0]==c||a[1]==c)
{
printf("Yes\n");
continue;
}
int sign=0;
for(int i=2;i<50;i++)
{
a[i]=a[i-1]+a[i-2];
if(a[i]==c)
{
sign=1;
break;
}
}
if(sign)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
hdu 5018 Revenge of Fibonacci(BestCoder Round #10)
标签:algorithm
原文地址:http://blog.csdn.net/caduca/article/details/39429547