92792024-02-19 17:45:10NagyLeoFőzet készítéspypy3Runtime error 20/50352ms93512 KiB
import math
from sys import stdin
input=stdin.readline

def main():
    MAXAB=301
    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
base20/50
1Accepted0/0310ms87912 KiB
2Accepted0/0333ms90884 KiB
3Accepted3/3319ms89228 KiB
4Accepted2/2319ms88960 KiB
5Accepted3/3314ms89128 KiB
6Accepted2/2319ms89576 KiB
7Accepted3/3352ms92136 KiB
8Accepted2/2344ms92244 KiB
9Accepted3/3344ms92772 KiB
10Accepted2/2342ms92560 KiB
11Runtime error0/2340ms91964 KiB
12Runtime error0/2340ms91472 KiB
13Runtime error0/2335ms92184 KiB
14Runtime error0/2340ms92304 KiB
15Runtime error0/2333ms92512 KiB
16Runtime error0/2340ms92532 KiB
17Runtime error0/2335ms92972 KiB
18Runtime error0/2330ms93036 KiB
19Runtime error0/2330ms93312 KiB
20Runtime error0/3340ms93364 KiB
21Runtime error0/3333ms93512 KiB
22Runtime error0/3331ms93204 KiB
23Runtime error0/3340ms93308 KiB