29562023-02-06 07:48:51bzsofiaFőzet készítéscpp11Time limit exceeded 0/50551ms4728 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))
            {
                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/0462ms1976 KiB
2Time limit exceeded0/0463ms2188 KiB
3Time limit exceeded0/3467ms2464 KiB
4Time limit exceeded0/2551ms2696 KiB
5Time limit exceeded0/3467ms2924 KiB
6Time limit exceeded0/2547ms3144 KiB
7Time limit exceeded0/3470ms3184 KiB
8Time limit exceeded0/2544ms3220 KiB
9Time limit exceeded0/3456ms3228 KiB
10Time limit exceeded0/2467ms3424 KiB
11Time limit exceeded0/2472ms3292 KiB
12Time limit exceeded0/2467ms3428 KiB
13Time limit exceeded0/2542ms3380 KiB
14Time limit exceeded0/2483ms3564 KiB
15Time limit exceeded0/2465ms4012 KiB
16Time limit exceeded0/2462ms4260 KiB
17Time limit exceeded0/2550ms4432 KiB
18Time limit exceeded0/2463ms4052 KiB
19Time limit exceeded0/2476ms4176 KiB
20Time limit exceeded0/3467ms4332 KiB
21Time limit exceeded0/3470ms4284 KiB
22Time limit exceeded0/3469ms4480 KiB
23Time limit exceeded0/3469ms4728 KiB