29582023-02-06 07:54:31bzsofiaFőzet készítéscpp11Time limit exceeded 0/50460ms5812 KiB
#include <iostream>
#include <vector>

using namespace std;

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

int gcd(int a, int b)
{
	while (a!=0 && b != 0)
	{
		if (a <= b) b %= a;
		else a %= b;
	}

	return a + b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.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/0458ms4004 KiB
2Time limit exceeded0/0455ms2332 KiB
3Time limit exceeded0/3458ms4584 KiB
4Time limit exceeded0/2458ms4620 KiB
5Time limit exceeded0/3458ms4816 KiB
6Time limit exceeded0/2458ms4856 KiB
7Time limit exceeded0/3460ms4920 KiB
8Time limit exceeded0/2460ms3264 KiB
9Time limit exceeded0/3456ms3436 KiB
10Time limit exceeded0/2460ms5268 KiB
11Time limit exceeded0/2460ms5280 KiB
12Time limit exceeded0/2453ms3468 KiB
13Time limit exceeded0/2460ms5284 KiB
14Time limit exceeded0/2460ms5508 KiB
15Time limit exceeded0/2458ms5488 KiB
16Time limit exceeded0/2460ms5492 KiB
17Time limit exceeded0/2460ms5752 KiB
18Time limit exceeded0/2460ms5636 KiB
19Time limit exceeded0/2456ms3920 KiB
20Time limit exceeded0/3453ms3992 KiB
21Time limit exceeded0/3458ms5812 KiB
22Time limit exceeded0/3460ms5712 KiB
23Time limit exceeded0/3458ms4116 KiB