116392024-11-02 12:04:59MagyarKendeSZLGFőzet készítéscpp17Accepted 50/5041ms1620 KiB
// huge if works
#pragma GCC optimize("Ofast,unroll-loops")

// got inspired by the submission of peti1234
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);

    vector dp(501, vector<int>(501));
    for (int i = 1; i < 32; i++) {
        for (int j = 1; j < 32; j++) {
            if ((i > 10 && j > 10) || gcd(i, j) > 1)
                continue;
            for (int k = 500; k >= i; k--) {
                for (int l = 500; l >= j; l--) {
                    dp[k][l] =
                        max(dp[k][l], dp[k - i][l - j] + 1);
                }
            }
        }
    }

    int T;
    cin >> T;
    while (T--) {
        int A, B;
        cin >> A >> B;
        cout << dp[A][B] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/039ms1516 KiB
2Accepted0/039ms1424 KiB
3Accepted3/339ms1340 KiB
4Accepted2/239ms1336 KiB
5Accepted3/341ms1424 KiB
6Accepted2/239ms1336 KiB
7Accepted3/339ms1424 KiB
8Accepted2/241ms1504 KiB
9Accepted3/341ms1424 KiB
10Accepted2/241ms1336 KiB
11Accepted2/241ms1420 KiB
12Accepted2/239ms1432 KiB
13Accepted2/241ms1520 KiB
14Accepted2/239ms1620 KiB
15Accepted2/239ms1420 KiB
16Accepted2/239ms1336 KiB
17Accepted2/239ms1336 KiB
18Accepted2/239ms1336 KiB
19Accepted2/241ms1352 KiB
20Accepted3/339ms1336 KiB
21Accepted3/339ms1336 KiB
22Accepted3/341ms1536 KiB
23Accepted3/341ms1336 KiB