95622024-02-23 09:13:29csaron71Főzet készítéscpp17Accepted 50/50151ms5596 KiB
#include <bits/stdc++.h>
#include <queue>
using namespace std;

int main() {
	vector<vector<int> > dp(501, vector<int>(501, 0));
	for (int x=1; x<32; x++) {
		for (int y=1; y<32; y++) {
			if (__gcd(x, y)==1) {
				for (int i=500; i>=x; i--) {
					for (int j=500; j>=y; j--) {
						dp[i][j]=max(dp[i][j], dp[i-x][j-y]+1);
					}
				}
			}
			
		}
	}

	int t;
	cin >> t;
	while (t--) {
		int x, y;
		cin >> x >> y;
		cout << dp[x][y] << "\n";
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0149ms3836 KiB
2Accepted0/0150ms4188 KiB
3Accepted3/3149ms4352 KiB
4Accepted2/2149ms4524 KiB
5Accepted3/3148ms4744 KiB
6Accepted2/2149ms4768 KiB
7Accepted3/3150ms4936 KiB
8Accepted2/2151ms5052 KiB
9Accepted3/3150ms4992 KiB
10Accepted2/2150ms5036 KiB
11Accepted2/2150ms5044 KiB
12Accepted2/2151ms5028 KiB
13Accepted2/2151ms4944 KiB
14Accepted2/2151ms5228 KiB
15Accepted2/2151ms5376 KiB
16Accepted2/2151ms5172 KiB
17Accepted2/2150ms5300 KiB
18Accepted2/2150ms5280 KiB
19Accepted2/2150ms5188 KiB
20Accepted3/3150ms5180 KiB
21Accepted3/3150ms5180 KiB
22Accepted3/3150ms5300 KiB
23Accepted3/3151ms5596 KiB