結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,588 KB
testcase_01 AC 55 ms
64,456 KB
testcase_02 AC 37 ms
53,588 KB
testcase_03 AC 37 ms
53,588 KB
testcase_04 AC 37 ms
53,588 KB
testcase_05 AC 37 ms
53,588 KB
testcase_06 AC 37 ms
53,588 KB
testcase_07 AC 54 ms
64,468 KB
testcase_08 AC 56 ms
66,528 KB
testcase_09 WA -
testcase_10 AC 53 ms
64,460 KB
testcase_11 AC 53 ms
66,512 KB
testcase_12 AC 49 ms
62,388 KB
testcase_13 AC 52 ms
64,460 KB
testcase_14 AC 52 ms
64,468 KB
testcase_15 AC 53 ms
64,472 KB
testcase_16 AC 54 ms
64,480 KB
testcase_17 AC 53 ms
64,460 KB
testcase_18 AC 50 ms
62,388 KB
testcase_19 AC 52 ms
64,464 KB
testcase_20 AC 51 ms
64,464 KB
testcase_21 AC 51 ms
64,460 KB
testcase_22 AC 54 ms
64,460 KB
testcase_23 AC 53 ms
64,460 KB
testcase_24 AC 56 ms
66,532 KB
testcase_25 AC 38 ms
53,588 KB
testcase_26 AC 47 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=2*a-y
        b,c=(t-y)//2,(t-z)//2
        if a<b+c:ans.append((a,b,c))
    print(len(ans))
    for a,b,c in ans:print(a,b,c)

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