92782024-02-19 17:44:41NagyLeoFőzet készítéspypy3Time limit exceeded 0/50527ms94896 KiB
import math
from sys import stdin
input=stdin.readline

def main():
    MAXAB=401
    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/0483ms25520 KiB
2Time limit exceeded0/0483ms25532 KiB
3Time limit exceeded0/3476ms26012 KiB
4Time limit exceeded0/2470ms26108 KiB
5Time limit exceeded0/3470ms26332 KiB
6Time limit exceeded0/2477ms26684 KiB
7Time limit exceeded0/3476ms26728 KiB
8Time limit exceeded0/2467ms27120 KiB
9Time limit exceeded0/3490ms27320 KiB
10Time limit exceeded0/2465ms27648 KiB
11Time limit exceeded0/2527ms94896 KiB
12Time limit exceeded0/2458ms28076 KiB
13Time limit exceeded0/2477ms28088 KiB
14Time limit exceeded0/2458ms28060 KiB
15Time limit exceeded0/2474ms28164 KiB
16Time limit exceeded0/2488ms28556 KiB
17Time limit exceeded0/2488ms28464 KiB
18Time limit exceeded0/2472ms28632 KiB
19Time limit exceeded0/2465ms28616 KiB
20Time limit exceeded0/3474ms28668 KiB
21Time limit exceeded0/3474ms28948 KiB
22Time limit exceeded0/3479ms28848 KiB
23Time limit exceeded0/3465ms28844 KiB