43352023-03-25 12:37:44horvathabelFőzet készítéscpp17Accepted 50/50152ms6484 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
vector<vector<int>> dp;
dp.resize(501, vector<int>(501,0));
 
for (int i=1; i<32;i++){
	for (int j=1; j<32;j++){
		if (__gcd(i,j)==1){
		for (int k=500;k>=i;k--){
			for (int z=500;z>=j;z--){
				dp[k][z]=max(dp[k][z],dp[k-i][z-j]+1);		
	
				}
		}
	}
}
}
	int t;
	cin>>t; 
	for (int i=0; i<t;i++){
		int a,b;
		cin>>a>>b;
		cout<<dp[a][b]<<endl;
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0148ms3836 KiB
2Accepted0/0150ms4100 KiB
3Accepted3/3148ms4172 KiB
4Accepted2/2146ms4336 KiB
5Accepted3/3148ms4424 KiB
6Accepted2/2148ms4684 KiB
7Accepted3/3151ms4500 KiB
8Accepted2/2150ms4764 KiB
9Accepted3/3150ms5052 KiB
10Accepted2/2150ms5292 KiB
11Accepted2/2150ms5424 KiB
12Accepted2/2150ms5628 KiB
13Accepted2/2150ms5900 KiB
14Accepted2/2152ms6168 KiB
15Accepted2/2151ms6204 KiB
16Accepted2/2150ms5996 KiB
17Accepted2/2150ms5996 KiB
18Accepted2/2150ms6008 KiB
19Accepted2/2150ms5996 KiB
20Accepted3/3150ms6252 KiB
21Accepted3/3150ms6360 KiB
22Accepted3/3150ms6248 KiB
23Accepted3/3150ms6484 KiB