89892024-02-10 20:46:49xxxFőzet készítéscpp17Accepted 50/50238ms8504 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	
	bool grid[33][33] = {0};
	int dp[501][501] = {0};
	for(int i = 1; i <= 32; i++) {
		for(int j = 1; j <= 32; j++) {
			if (gcd(i, j) == 1) {
				cerr << i << ' ' << j << endl;
				for(int a = 500; a > 0; a--) {
					for(int b = 500; b > 0; b--) {
						if (a-i >= 0 && b-j >= 0) dp[a][b] = max(dp[a][b], dp[a-i][b-j]+1);
					}
				}
			}
		}
	}

	int n;
	cin >> n;
	int x, y;

	for(int i = 0; i < n; i++) {
		cin >> x >> y;
		cout << dp[x][y] << '\n';
	}
	
	
	return 0;
	
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0231ms5748 KiB
2Accepted0/0237ms6076 KiB
3Accepted3/3231ms6300 KiB
4Accepted2/2231ms6628 KiB
5Accepted3/3234ms6848 KiB
6Accepted2/2231ms6932 KiB
7Accepted3/3234ms6944 KiB
8Accepted2/2236ms7064 KiB
9Accepted3/3237ms7048 KiB
10Accepted2/2237ms7320 KiB
11Accepted2/2238ms7304 KiB
12Accepted2/2236ms7732 KiB
13Accepted2/2236ms7816 KiB
14Accepted2/2236ms7776 KiB
15Accepted2/2237ms7972 KiB
16Accepted2/2237ms8084 KiB
17Accepted2/2236ms8160 KiB
18Accepted2/2237ms8400 KiB
19Accepted2/2236ms8504 KiB
20Accepted3/3236ms8376 KiB
21Accepted3/3236ms8260 KiB
22Accepted3/3236ms8276 KiB
23Accepted3/3236ms8300 KiB