96422024-02-23 16:58:47PallanekPéterFőzet készítéscpp17Accepted 50/50151ms7040 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/0148ms3868 KiB
2Accepted0/0150ms4288 KiB
3Accepted3/3148ms4360 KiB
4Accepted2/2148ms4572 KiB
5Accepted3/3148ms4680 KiB
6Accepted2/2148ms4940 KiB
7Accepted3/3151ms5480 KiB
8Accepted2/2150ms5368 KiB
9Accepted3/3151ms5520 KiB
10Accepted2/2150ms5684 KiB
11Accepted2/2151ms5844 KiB
12Accepted2/2151ms6124 KiB
13Accepted2/2151ms6260 KiB
14Accepted2/2151ms6364 KiB
15Accepted2/2150ms6256 KiB
16Accepted2/2150ms6448 KiB
17Accepted2/2150ms6408 KiB
18Accepted2/2150ms6420 KiB
19Accepted2/2150ms6820 KiB
20Accepted3/3150ms6856 KiB
21Accepted3/3150ms6620 KiB
22Accepted3/3150ms6632 KiB
23Accepted3/3150ms7040 KiB