92802024-02-19 17:45:50NagyLeoFőzet készítéspypy3Runtime error 20/50444ms93476 KiB
import math
from sys import stdin
input=stdin.readline

def main():
    MAXAB=351
    matrix = [[0]*MAXAB for i in range(MAXAB)]
    X=[0,32,26,22,19,17,17,15,14,13,13,12,11,9,8,7,7,5,5,4,4,4,3,3,3,3,2,2,2,2,2,2]
    for i in range(1, 32):
        for j in range(1,X[i]):
            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/0414ms88972 KiB
2Accepted0/0444ms91252 KiB
3Accepted3/3405ms89480 KiB
4Accepted2/2409ms89620 KiB
5Accepted3/3404ms89972 KiB
6Accepted2/2400ms90384 KiB
7Accepted3/3423ms92612 KiB
8Accepted2/2423ms92512 KiB
9Accepted3/3423ms92616 KiB
10Accepted2/2425ms92892 KiB
11Runtime error0/2423ms91840 KiB
12Runtime error0/2421ms92064 KiB
13Runtime error0/2421ms91984 KiB
14Runtime error0/2432ms92272 KiB
15Runtime error0/2428ms92332 KiB
16Runtime error0/2421ms92332 KiB
17Runtime error0/2432ms92264 KiB
18Runtime error0/2425ms92808 KiB
19Runtime error0/2432ms93016 KiB
20Runtime error0/3430ms93476 KiB
21Runtime error0/3428ms93148 KiB
22Runtime error0/3430ms93176 KiB
23Runtime error0/3425ms93348 KiB