92752024-02-19 17:41:09NagyLeoFőzet készítéspypy3Runtime error 20/50330ms92460 KiB
import math
from sys import stdin, stdout
input=stdin.readline

def main():
    MAXAB=151
    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
base20/50
1Accepted0/0300ms87276 KiB
2Accepted0/0321ms88964 KiB
3Accepted3/3300ms88036 KiB
4Accepted2/2307ms88308 KiB
5Accepted3/3300ms88520 KiB
6Accepted2/2300ms88108 KiB
7Accepted3/3323ms90068 KiB
8Accepted2/2321ms90092 KiB
9Accepted3/3321ms90248 KiB
10Accepted2/2321ms90344 KiB
11Runtime error0/2323ms90940 KiB
12Runtime error0/2330ms91196 KiB
13Runtime error0/2328ms90852 KiB
14Runtime error0/2321ms91148 KiB
15Runtime error0/2321ms91380 KiB
16Runtime error0/2321ms91564 KiB
17Runtime error0/2317ms91764 KiB
18Runtime error0/2321ms91788 KiB
19Runtime error0/2321ms92100 KiB
20Runtime error0/3321ms91984 KiB
21Runtime error0/3316ms92196 KiB
22Runtime error0/3321ms92384 KiB
23Runtime error0/3321ms92460 KiB