10402022-02-27 11:50:31Szin AttilaFőzet készítéscpp14Wrong answer 48/50289ms3364 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 <= 30; 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
base48/50
1Accepted0/0264ms3056 KiB
2Accepted0/0279ms3096 KiB
3Accepted3/3266ms3104 KiB
4Accepted2/2259ms3096 KiB
5Accepted3/3259ms3108 KiB
6Accepted2/2268ms3104 KiB
7Accepted3/3268ms3124 KiB
8Accepted2/2272ms3136 KiB
9Accepted3/3289ms3136 KiB
10Accepted2/2264ms3152 KiB
11Wrong answer0/2259ms3188 KiB
12Accepted2/2270ms3188 KiB
13Accepted2/2264ms3204 KiB
14Accepted2/2266ms3228 KiB
15Accepted2/2272ms3228 KiB
16Accepted2/2268ms3256 KiB
17Accepted2/2273ms3268 KiB
18Accepted2/2256ms3284 KiB
19Accepted2/2264ms3300 KiB
20Accepted3/3266ms3316 KiB
21Accepted3/3268ms3332 KiB
22Accepted3/3259ms3348 KiB
23Accepted3/3264ms3364 KiB