29572023-02-06 07:49:42bzsofiaFőzet készítéscpp11Time limit exceeded 0/50462ms6576 KiB
#include <bits/stdc++.h>

using namespace std;

int i, j, a, b, t;
vector <vector <int>> dp(501, vector<int>(501));

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    for (i=1; i<32; ++i)
    {
        for (j=1; j<32; ++j)
        {
            if (__gcd(i,j)==1)
            {
                for (a=500; a>=i; --a)
                {
                    for (b=500; b>=j; --b)
                    {
                        dp[a][b]=max(dp[a][b], dp[a-i][b-j]+1);
                    }
                }
            }
        }
    }

    cin>>t;
    for (i=1; i<=t; ++i)
    {
        cin>>a>>b;
        cout<<dp[a][b]<<"\n";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Time limit exceeded0/0462ms3720 KiB
2Time limit exceeded0/0462ms3892 KiB
3Time limit exceeded0/3456ms2400 KiB
4Time limit exceeded0/2460ms2652 KiB
5Time limit exceeded0/3462ms4568 KiB
6Time limit exceeded0/2451ms3068 KiB
7Time limit exceeded0/3460ms4872 KiB
8Time limit exceeded0/2462ms4804 KiB
9Time limit exceeded0/3462ms4924 KiB
10Time limit exceeded0/2462ms5164 KiB
11Time limit exceeded0/2460ms5248 KiB
12Time limit exceeded0/2460ms5152 KiB
13Time limit exceeded0/2460ms3584 KiB
14Time limit exceeded0/2453ms3844 KiB
15Time limit exceeded0/2460ms4044 KiB
16Time limit exceeded0/2462ms5996 KiB
17Time limit exceeded0/2462ms6084 KiB
18Time limit exceeded0/2462ms6192 KiB
19Time limit exceeded0/2460ms4444 KiB
20Time limit exceeded0/3462ms6228 KiB
21Time limit exceeded0/3462ms6460 KiB
22Time limit exceeded0/3462ms6576 KiB
23Time limit exceeded0/3462ms6448 KiB