89872024-02-10 20:46:29xxxFőzet készítéspython3Runtime error 0/5017ms13592 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
base0/50
1Runtime error0/017ms10872 KiB
2Runtime error0/017ms11216 KiB
3Runtime error0/317ms11452 KiB
4Runtime error0/217ms12036 KiB
5Runtime error0/317ms11900 KiB
6Runtime error0/217ms12320 KiB
7Runtime error0/317ms12404 KiB
8Runtime error0/217ms12552 KiB
9Runtime error0/317ms12560 KiB
10Runtime error0/217ms12760 KiB
11Runtime error0/217ms12792 KiB
12Runtime error0/217ms12756 KiB
13Runtime error0/217ms12948 KiB
14Runtime error0/217ms12832 KiB
15Runtime error0/217ms13040 KiB
16Runtime error0/217ms13000 KiB
17Runtime error0/217ms12932 KiB
18Runtime error0/217ms12696 KiB
19Runtime error0/217ms13140 KiB
20Runtime error0/317ms13256 KiB
21Runtime error0/317ms13052 KiB
22Runtime error0/317ms13376 KiB
23Runtime error0/317ms13592 KiB