92712024-02-19 17:38:03NagyLeoFőzet készítéspython3Time limit exceeded 0/50547ms6472 KiB
import math
from sys import stdin, stdout
input=stdin.readline

def main():
    MAXAB=101
    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
base0/50
1Time limit exceeded0/0499ms3876 KiB
2Time limit exceeded0/0456ms4112 KiB
3Time limit exceeded0/3479ms4384 KiB
4Time limit exceeded0/2547ms4728 KiB
5Time limit exceeded0/3540ms4924 KiB
6Time limit exceeded0/2472ms5172 KiB
7Time limit exceeded0/3479ms5248 KiB
8Time limit exceeded0/2483ms5200 KiB
9Time limit exceeded0/3479ms5272 KiB
10Time limit exceeded0/2467ms5528 KiB
11Time limit exceeded0/2463ms5672 KiB
12Time limit exceeded0/2523ms5828 KiB
13Time limit exceeded0/2486ms5848 KiB
14Time limit exceeded0/2467ms5840 KiB
15Time limit exceeded0/2463ms5956 KiB
16Time limit exceeded0/2479ms6244 KiB
17Time limit exceeded0/2460ms6144 KiB
18Time limit exceeded0/2479ms6184 KiB
19Time limit exceeded0/2460ms6460 KiB
20Time limit exceeded0/3476ms6472 KiB
21Time limit exceeded0/3456ms6392 KiB
22Time limit exceeded0/3456ms6412 KiB
23Time limit exceeded0/3476ms6412 KiB