92732024-02-19 17:39:29NagyLeoFőzet készítéspypy3Runtime error 20/50192ms92324 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
base20/50
1Accepted0/0150ms86996 KiB
2Accepted0/0172ms89840 KiB
3Accepted3/3150ms87360 KiB
4Accepted2/2158ms87388 KiB
5Accepted3/3153ms88212 KiB
6Accepted2/2150ms88380 KiB
7Accepted3/3180ms90888 KiB
8Accepted2/2192ms90888 KiB
9Accepted3/3175ms90912 KiB
10Accepted2/2172ms91340 KiB
11Runtime error0/2180ms90536 KiB
12Runtime error0/2180ms90892 KiB
13Runtime error0/2180ms91228 KiB
14Runtime error0/2173ms91020 KiB
15Runtime error0/2179ms91480 KiB
16Runtime error0/2172ms91560 KiB
17Runtime error0/2179ms91656 KiB
18Runtime error0/2172ms91868 KiB
19Runtime error0/2180ms91932 KiB
20Runtime error0/3173ms92324 KiB
21Runtime error0/3170ms92124 KiB
22Runtime error0/3180ms92084 KiB
23Runtime error0/3173ms92144 KiB