待解决题目

待解决题目

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define pdi pair<double, int>
#define x first
#define y second
const int N = 500 + 10;
int t, f[N];
struct node{
	int x, y, x2, y2;	
}a[N];
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> t;
	a[1] = {-1, 0, 0, 1}, f[1] = 1;
	a[2] = {-1, -1, 0, 0}, f[2] = 1;
	a[3] = {0, -1, 2, 1}, f[3] = 2;
	a[4] = {-1, 1, 2, 4}, f[4] = 3;
	int tot = 1;
	for(int i = 5; i <= 90; i++){
		f[i] = f[i - 1] + f[i - 2];
		if(tot == 1){
			a[i] = {a[i - 1].x - f[i], a[i - 1].y - (f[i] - f[i - 1]), a[i - 1].x, a[i - 1].y + f[i - 1]};
			tot = 2;
		}else if(tot == 2){
			a[i] = {a[i - 1].x, a[i - 1].y - f[i], a[i - 1].x + f[i], a[i - 1].y};
			tot = 3;
		}else if(tot == 3){
			a[i] = {a[i - 1].x2, a[i - 1].y, a[i - 1].x2 + f[i], a[i - 1].y + f[i]};
			tot = 4;
		}else{
			a[i] = {a[i - 1].x2 - f[i], a[i - 1].y2, a[i - 1].x2, a[i - 1].y2 + f[i]};
			tot = 1;
		}
	}
	while(t--){
		int x, y;
		cin >> x >> y;
		for(int i = 1; i <= 90; i++){
			if(a[i].x <= x && x <= a[i].x2 && a[i].y <= y && y <= a[i].y2){
				cout << f[i] << '\n';
				break;
			}
		}
	}
	return 0;
}

评论