您的位置:首页 > 其它

HDU 5018 Revenge of Fibonacci

2016-02-26 20:00 357 查看
求第三个数字是不是类Fib数列中的一项

#include<iostream>
#include<cstdio>
#include<set>
#include<string>
#include<string.h>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<algorithm>
#include<sstream>
#include<utility>
#include<cmath>
#define mt(a) memset(a,0,sizeof (a))
#define fl(a,b,c) fill(a,b,c)
#define SWAP(a,b,t) (t=a,a=b,b=t)
#define inf 1000000

using namespace std;

typedef long long ll;

int main()
{
int T;
cin >> T;
while (T--)
{
ll x, y, z,t;
scanf("%lld %lld %lld", &x, &y,&z);
if (x == z || y == z){
puts("Yes"); continue;
}
while (1)
{
t = x + y;
if (t < z)
{
x = y;
y = t;
}
else if (t == z)
{
puts("Yes");
break;
}
else if (t>z)
{
puts("No");
break;
}
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: