結果
| 問題 | No.1626 三角形の構築 | 
| コンテスト | |
| ユーザー |  mkawa2 | 
| 提出日時 | 2024-02-04 16:49:11 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 69 ms / 2,000 ms | 
| コード長 | 1,514 bytes | 
| コンパイル時間 | 189 ms | 
| コンパイル使用メモリ | 81,988 KB | 
| 実行使用メモリ | 66,688 KB | 
| 最終ジャッジ日時 | 2024-09-28 11:19:39 | 
| 合計ジャッジ時間 | 2,876 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 26 | 
ソースコード
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
        if (t ^ y) & 1: continue
        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()
            
            
            
        