93542024-02-20 19:31:15AblablablaFőzet készítéscpp17Accepted 50/5087ms6532 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    vector<vector<int>> dp(501, vector<int>(501, 0));

    for(int a = 1; a < 32; a++){
        for(int b = 1; b < 32; b++){
            if(a > 10 && b > 10 || __gcd(a, b) != 1) continue;

            for(int i = 500 - a; i >= 0; i--){
                for(int j = 500 - b; j >= 0; j--){
                    dp[i + a][j + b] = max(dp[i + a][j + b], dp[i][j] + 1);
                }
            }
        }
    }

    int t;
    cin >> t;
    while(t--){
        int a, b;
        cin >> a >> b;
        cout << dp[a][b] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/082ms3840 KiB
2Accepted0/086ms4040 KiB
3Accepted3/382ms4216 KiB
4Accepted2/282ms4420 KiB
5Accepted3/382ms4744 KiB
6Accepted2/282ms4584 KiB
7Accepted3/385ms4840 KiB
8Accepted2/286ms4936 KiB
9Accepted3/385ms4892 KiB
10Accepted2/285ms4900 KiB
11Accepted2/286ms4904 KiB
12Accepted2/286ms5148 KiB
13Accepted2/286ms5356 KiB
14Accepted2/286ms5300 KiB
15Accepted2/285ms5320 KiB
16Accepted2/285ms5316 KiB
17Accepted2/286ms5308 KiB
18Accepted2/287ms5824 KiB
19Accepted2/286ms6000 KiB
20Accepted3/386ms6264 KiB
21Accepted3/387ms6532 KiB
22Accepted3/385ms6468 KiB
23Accepted3/387ms6476 KiB