92722024-02-19 17:38:38NagyLeoFőzet készítéspython3Runtime error 10/50338ms14192 KiB
import math
from sys import stdin, stdout
input=stdin.readline

def main():
    MAXAB=50
    matrix = [[0]*MAXAB for i in range(MAXAB)]
    for i in range(1, 33):
        for j in range(1, 33):
            if math.gcd(i, j) > 1:
                continue
            # i,j lehetseges fozet
            for k in range(MAXAB-1, i-1, -1):
                for l in range(MAXAB-1, j-1, -1):
                    matrix[k][l] = max(matrix[k][l], matrix[k-i][l-j]+1)

    N = int(input())
    for _ in range(N):
        A, B = map(int, input().split())
        print(matrix[A][B])

main()
SubtaskSumTestVerdictTimeMemory
base10/50
1Accepted0/0326ms11392 KiB
2Runtime error0/0326ms11576 KiB
3Accepted3/3326ms11880 KiB
4Accepted2/2324ms12256 KiB
5Accepted3/3338ms12564 KiB
6Accepted2/2326ms12732 KiB
7Runtime error0/3324ms12276 KiB
8Runtime error0/2326ms12520 KiB
9Runtime error0/3333ms12940 KiB
10Runtime error0/2331ms13036 KiB
11Runtime error0/2326ms13096 KiB
12Runtime error0/2326ms13140 KiB
13Runtime error0/2324ms13172 KiB
14Runtime error0/2326ms13512 KiB
15Runtime error0/2326ms13584 KiB
16Runtime error0/2326ms13676 KiB
17Runtime error0/2331ms13952 KiB
18Runtime error0/2326ms14192 KiB
19Runtime error0/2326ms13904 KiB
20Runtime error0/3328ms14044 KiB
21Runtime error0/3326ms13968 KiB
22Runtime error0/3324ms13960 KiB
23Runtime error0/3333ms13964 KiB