結果

問題 No.1626 三角形の構築
ユーザー mkawa2mkawa2
提出日時 2024-02-04 16:39:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,481 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 66,552 KB
最終ジャッジ日時 2024-02-04 16:39:21
合計ジャッジ時間 2,696 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,588 KB
testcase_01 AC 49 ms
64,456 KB
testcase_02 AC 35 ms
53,584 KB
testcase_03 AC 36 ms
53,588 KB
testcase_04 AC 35 ms
53,588 KB
testcase_05 AC 36 ms
53,588 KB
testcase_06 AC 35 ms
53,588 KB
testcase_07 AC 53 ms
64,468 KB
testcase_08 AC 56 ms
66,528 KB
testcase_09 WA -
testcase_10 AC 51 ms
64,460 KB
testcase_11 AC 51 ms
66,512 KB
testcase_12 AC 46 ms
62,388 KB
testcase_13 AC 48 ms
64,460 KB
testcase_14 AC 55 ms
64,468 KB
testcase_15 AC 50 ms
64,472 KB
testcase_16 AC 52 ms
64,480 KB
testcase_17 AC 48 ms
64,460 KB
testcase_18 AC 48 ms
62,388 KB
testcase_19 AC 49 ms
64,464 KB
testcase_20 AC 47 ms
64,464 KB
testcase_21 AC 49 ms
64,460 KB
testcase_22 AC 50 ms
64,460 KB
testcase_23 AC 50 ms
64,460 KB
testcase_24 AC 53 ms
66,532 KB
testcase_25 AC 35 ms
53,588 KB
testcase_26 AC 45 ms
62,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

# 16s2/t=(t-2a)(t-2b)(t-2c)
# 16s2/t=xyz
# a+(t-y)/2+(t-z)/2=t
# 2a+t-y+t-z=2t
# 2a+t-y+t-z=2t
# y+z=2a
# y2-2ay+v=0
# y=a-sqrt(a2-v)

from math import isqrt

def solve():
    s, t = LI()
    s = s*s*16
    if s%t:
        print(0)
        return
    s //= t
    ans = []
    for x in range(2-(t & 1), t-1, 2):
        if x**3 > s: break
        if s%x: continue
        a = (t-x)//2
        v = s//x
        if a*a-v < 0: continue
        r = isqrt(a*a-v)
        if r*r != a*a-v: continue
        y = a-r
        if y < x: break
        z = a+r
        b, c = (t-y)//2, (t-z)//2
        if a < b+c: ans.append((c, b, a))
    print(len(ans))
    for a, b, c in ans: print(a, b, c)

for _ in range(II()): solve()
0