10422022-02-27 11:51:57Szin AttilaFőzet készítéscpp14Accepted 50/50331ms3184 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxN = 500;
const int MOD = 1e9 + 7;

short dp[501][501];


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

    vector<pair<int, int>> v;

    for(int i = 1; i <= 35; i++) {
        for(int j = 1; j <= 35; j++) {
            if(__gcd(i, j) == 1) v.push_back({i, j});
        }
    }

    for(int i = 1; i <= v.size(); i++) {
        for(int j = maxN; j > 0; j--) {
            for(int l = maxN; l > 0; l--) {
                if(v[i-1].first <= j && v[i-1].second <= l) {
                    dp[j][l] = max(dp[j][l], (short)(dp[j - v[i-1].first][l - v[i-1].second] + 1));
                }
            }
        }
    }

    int t;
    cin >> t;
    while(t--) {
        int x,y;
        cin >> x >> y;

        cout << dp[x][y] << "\n";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0303ms2828 KiB
2Accepted0/0310ms2916 KiB
3Accepted3/3300ms2904 KiB
4Accepted2/2319ms2908 KiB
5Accepted3/3312ms2928 KiB
6Accepted2/2321ms2920 KiB
7Accepted3/3326ms2924 KiB
8Accepted2/2314ms2960 KiB
9Accepted3/3314ms2964 KiB
10Accepted2/2308ms2984 KiB
11Accepted2/2312ms2996 KiB
12Accepted2/2331ms3000 KiB
13Accepted2/2316ms3036 KiB
14Accepted2/2319ms3048 KiB
15Accepted2/2310ms3064 KiB
16Accepted2/2307ms3072 KiB
17Accepted2/2312ms3084 KiB
18Accepted2/2308ms3120 KiB
19Accepted2/2314ms3108 KiB
20Accepted3/3321ms3128 KiB
21Accepted3/3317ms3152 KiB
22Accepted3/3316ms3152 KiB
23Accepted3/3317ms3184 KiB