11032022-03-03 10:34:06kidesoFőzet készítéscpp14Accepted 50/50187ms4200 KiB
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 500;
int x[N + 1][N + 1];

int gcd(int i, int j) {
	int r = i % j;

	while (r){
		i = j;
		j = r;
		r = i % j;
	}

	return j;
}

int main() {
	
	for (int i = 1; i <= 32; ++i)
		for (int j = 1; j <= 32; ++j)
			if (gcd(i, j) == 1) {
				for (int a = N; a >= i; --a)
					for (int b = N; b >= j; --b)
						x[a][b] = max(x[a][b], x[a - i][b - j] + 1);
			}


	int T;
	cin >> T;
	while (T--) {
		int A, B;
		cin >> A >> B;
		cout << x[A][B] << '\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0168ms3852 KiB
2Accepted0/0177ms3888 KiB
3Accepted3/3178ms3908 KiB
4Accepted2/2172ms3912 KiB
5Accepted3/3168ms3908 KiB
6Accepted2/2172ms3912 KiB
7Accepted3/3179ms3924 KiB
8Accepted2/2180ms3936 KiB
9Accepted3/3172ms3956 KiB
10Accepted2/2172ms3968 KiB
11Accepted2/2179ms3988 KiB
12Accepted2/2172ms4004 KiB
13Accepted2/2173ms4004 KiB
14Accepted2/2178ms4028 KiB
15Accepted2/2175ms4044 KiB
16Accepted2/2172ms4060 KiB
17Accepted2/2175ms4076 KiB
18Accepted2/2187ms4092 KiB
19Accepted2/2173ms4120 KiB
20Accepted3/3181ms4136 KiB
21Accepted3/3174ms4168 KiB
22Accepted3/3172ms4192 KiB
23Accepted3/3172ms4200 KiB