92762024-02-19 17:41:39NagyLeoFőzet készítéspypy3Time limit exceeded 0/50529ms93012 KiB
import math
from sys import stdin, stdout
input=stdin.readline

def main():
    MAXAB=201
    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/0479ms24704 KiB
2Time limit exceeded0/0460ms24972 KiB
3Time limit exceeded0/3503ms87824 KiB
4Time limit exceeded0/2501ms88172 KiB
5Time limit exceeded0/3458ms25488 KiB
6Time limit exceeded0/2467ms25688 KiB
7Time limit exceeded0/3526ms90928 KiB
8Time limit exceeded0/2476ms25800 KiB
9Time limit exceeded0/3476ms26128 KiB
10Time limit exceeded0/2523ms91200 KiB
11Time limit exceeded0/2462ms26332 KiB
12Time limit exceeded0/2458ms26856 KiB
13Time limit exceeded0/2470ms26736 KiB
14Time limit exceeded0/2474ms26752 KiB
15Time limit exceeded0/2458ms27136 KiB
16Time limit exceeded0/2524ms93012 KiB
17Time limit exceeded0/2474ms27116 KiB
18Time limit exceeded0/2476ms27280 KiB
19Time limit exceeded0/2483ms27496 KiB
20Time limit exceeded0/3477ms27688 KiB
21Time limit exceeded0/3529ms92184 KiB
22Time limit exceeded0/3524ms29080 KiB
23Time limit exceeded0/3477ms27984 KiB