96462024-02-23 17:02:03PallanekPéterFőzet készítéscpp17Accepted 50/50153ms6124 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<vector<int>> dp;
    dp.resize(501, vector<int>(501,0));
    for (int a=1; a<32; a++){
        for (int b=1; b<32; b++){
            if (__gcd(a,b)==1){
                for (int i=500; i>=a; i--) {
                    for (int j=500; j>=b; j--) {
                        dp[i][j]=max(dp[i][j],dp[i-a][j-b]+1);
                    }
                }
            }
        }
    }
    int t;
    cin >> t;
    for (int i=0; i<t; i++) {
        int x, y;
        cin >> x >> y;
        cout << dp[x][y] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0149ms3984 KiB
2Accepted0/0151ms4064 KiB
3Accepted3/3149ms4276 KiB
4Accepted2/2149ms4636 KiB
5Accepted3/3149ms4432 KiB
6Accepted2/2149ms4688 KiB
7Accepted3/3151ms4900 KiB
8Accepted2/2151ms5108 KiB
9Accepted3/3151ms5344 KiB
10Accepted2/2150ms5336 KiB
11Accepted2/2151ms5484 KiB
12Accepted2/2151ms5708 KiB
13Accepted2/2151ms5500 KiB
14Accepted2/2151ms5636 KiB
15Accepted2/2151ms5652 KiB
16Accepted2/2151ms5644 KiB
17Accepted2/2151ms5648 KiB
18Accepted2/2151ms5772 KiB
19Accepted2/2151ms5792 KiB
20Accepted3/3151ms5712 KiB
21Accepted3/3151ms5980 KiB
22Accepted3/3153ms6116 KiB
23Accepted3/3151ms6124 KiB