题目链接:https://codeforces.com/contest/1811/problem/D
思维题,昨天被E题搞太久了,这题认真想的话应该可以出的。
思路:不断循环,判断x和y是否在合法区间内。
代码:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+10;
long long fib[70];
void solve(){
int n,x,y;
cin>>n>>x>>y;
bool flag = 1;
while(n){
if (y>fib[n]||y<=fib[n-1]) {
if (y>fib[n]) y -= fib[n];
}else{
flag = 0;
break;
}
n--;
swap(x,y);
}
if (flag) cout<<"Yes\n";
else cout<<"No\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
fib[0] = 1,fib[1] = 1;
for (int i=2;i<=50;i++) fib[i] = fib[i-1]+fib[i-2];
int T;
T = 1;
cin>>T;
while(T--) solve();
return 0;
}
标签:int,cf,fib,--,flag,div.3,863d
From: https://www.cnblogs.com/xjwrr/p/17289231.html