44912023-03-29 09:55:32gortomiFőzet készítéscpp17Accepted 50/50165ms6232 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int c = 33;
    vector<vector<int> > dp(501, vector<int>(501));
    for(int i = 1; i <= c; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            if(__gcd(i, j) == 1)
            {
                for(int k = 500; k >= i; k--)
                {
                    for(int l = 500; l >= j; l--)
                    {
                        dp[k][l] = max(dp[k - i][l - j] + 1, dp[k][l]);
                    }
                }
            }
        }
    }
    int t;
    cin >> t;
    while(t--)
    {
        int x, y;
        cin >> x >> y;
        cout << dp[x][y] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/0165ms3628 KiB
2Accepted0/0165ms3880 KiB
3Accepted3/3165ms4092 KiB
4Accepted2/2165ms4304 KiB
5Accepted3/3165ms4516 KiB
6Accepted2/2165ms4668 KiB
7Accepted3/3165ms4748 KiB
8Accepted2/2165ms4996 KiB
9Accepted3/3165ms4992 KiB
10Accepted2/2165ms5088 KiB
11Accepted2/2165ms5320 KiB
12Accepted2/2165ms5520 KiB
13Accepted2/2165ms5408 KiB
14Accepted2/2165ms5408 KiB
15Accepted2/2165ms5648 KiB
16Accepted2/2165ms5648 KiB
17Accepted2/2165ms5768 KiB
18Accepted2/2165ms5824 KiB
19Accepted2/2165ms5824 KiB
20Accepted3/3165ms5972 KiB
21Accepted3/3165ms5976 KiB
22Accepted3/3165ms5864 KiB
23Accepted3/3165ms6232 KiB