Question :
Denote the -th Fibonacci number as
A checkered rectangle with a height of and a width of is called a Fibonacci rectangle of order .
Umka has a Fibonacci rectangle of order . Someone colored a cell in it at the intersection of the row and the column .
It is necessary to cut this rectangle exactly into squares in such way that
- the painted cell was in a square with a side of ;
- there was at most one pair of squares with equal sides;
- the side of each square was equal to a Fibonacci number.
Will Umka be able to cut this rectangle in that way?
The first line contains an integer () — number of test cases.
For each test case the integers , , are given (, , ) — the order of the Fibonacci rectangle and the coordinates of the colored cell.
For each test case, print "YES" if the answer is positive, and "NO" otherwise.
You can print "YES" and "NO" in any case (for example, the strings "yEs", "yes" and "Yes" will be recognized as a positive answer).
121 1 12 1 23 1 43 3 24 4 64 3 35 6 55 4 125 2 124 2 11 1 244 758465880 1277583853
YES NO YES YES YES NO YES NO NO YES YES NO
Explanation :
Solution :
using namespace std;
#define ll long long int
vector<ll> F;
bool solve(ll x, ll y, ll n){
if(n==1) return true;
if(min(y, F[n+1] - y + 1) > F[n+1] - F[n]){
return false;
}
y = min(y, F[n+1] - y + 1);
return solve(y,x,n-1);
}
int main(){
ll t,n,x1,y1,x2,y2;
cin>>t;
F.push_back(1);
F.push_back(1);
for(int i = 0;i<46;i++){
F.push_back(F[i] + F[i+1]);
}
while(t--){
cin>>n>>x1>>y1;
if(solve(x1,y1,n)){
cout<<"YES\n";
}else{
cout<<"NO\n";
}
}
return 0;
}