92772024-02-19 17:44:12NagyLeoFőzet készítéspypy3Time limit exceeded 0/50555ms29348 KiB
import math
from sys import stdin
input=stdin.readline

def main():
    MAXAB=501
    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
base0/50
1Time limit exceeded0/0485ms26176 KiB
2Time limit exceeded0/0490ms26532 KiB
3Time limit exceeded0/3458ms26488 KiB
4Time limit exceeded0/2555ms26964 KiB
5Time limit exceeded0/3483ms26964 KiB
6Time limit exceeded0/2546ms27200 KiB
7Time limit exceeded0/3547ms27436 KiB
8Time limit exceeded0/2486ms27700 KiB
9Time limit exceeded0/3467ms27940 KiB
10Time limit exceeded0/2463ms27884 KiB
11Time limit exceeded0/2474ms28204 KiB
12Time limit exceeded0/2470ms28476 KiB
13Time limit exceeded0/2462ms28524 KiB
14Time limit exceeded0/2472ms28520 KiB
15Time limit exceeded0/2483ms28668 KiB
16Time limit exceeded0/2503ms28612 KiB
17Time limit exceeded0/2474ms28640 KiB
18Time limit exceeded0/2479ms28636 KiB
19Time limit exceeded0/2476ms28900 KiB
20Time limit exceeded0/3469ms29280 KiB
21Time limit exceeded0/3472ms29236 KiB
22Time limit exceeded0/3481ms29332 KiB
23Time limit exceeded0/3465ms29348 KiB