結果

問題 No.1626 三角形の構築
ユーザー convexineqconvexineq
提出日時 2021-07-23 22:38:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,000 ms / 2,000 ms
コード長 1,290 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 79,488 KB
最終ジャッジ日時 2024-04-20 15:52:19
合計ジャッジ時間 5,279 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
59,392 KB
testcase_01 AC 139 ms
75,904 KB
testcase_02 AC 44 ms
57,984 KB
testcase_03 AC 50 ms
60,672 KB
testcase_04 AC 56 ms
62,464 KB
testcase_05 AC 60 ms
62,976 KB
testcase_06 AC 49 ms
60,160 KB
testcase_07 AC 111 ms
69,888 KB
testcase_08 AC 144 ms
72,032 KB
testcase_09 AC 192 ms
76,120 KB
testcase_10 AC 142 ms
73,344 KB
testcase_11 AC 157 ms
72,832 KB
testcase_12 AC 99 ms
69,888 KB
testcase_13 AC 85 ms
68,352 KB
testcase_14 AC 105 ms
65,792 KB
testcase_15 AC 122 ms
76,288 KB
testcase_16 AC 150 ms
72,704 KB
testcase_17 AC 127 ms
71,936 KB
testcase_18 AC 105 ms
70,784 KB
testcase_19 AC 138 ms
70,784 KB
testcase_20 AC 147 ms
73,344 KB
testcase_21 AC 135 ms
76,032 KB
testcase_22 AC 192 ms
76,116 KB
testcase_23 AC 158 ms
74,240 KB
testcase_24 AC 1,000 ms
79,488 KB
testcase_25 AC 39 ms
51,840 KB
testcase_26 AC 66 ms
66,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

def solve(n,t):
    if t%2: return []
    t //= 2
    N = n*n
    div = [1]
    for k,v in prime_factorize(n):
        ndiv = div[:]
        c = k
        for i in range(2*v):
            ndiv += [i*c for i in div]
            c *= k
        div = ndiv
    div.sort()
    # pqr(p+q+r) = n*n なる (p,q,r)を求める
    ans = 0
    L = len(div)
    res = []
    for i,p in enumerate(div):
        if p*p > n: break
        for j in range(i,L):
            q = div[j]
            if p*q*q*(p+q+q) > N: break
            if N%(p*q): continue
            r = t-p-q
            if r*t == N//p//q:
                res.append((p,q,r))
    return res

T = int(input())
for _ in range(T):
    s,t = map(int,input().split())
    r = solve(s,t)
    print(len(r))
    for a,b,c in r:
        print(a+b,b+c,c+a)
0