結果
問題 |
No.1626 三角形の構築
|
ユーザー |
![]() |
提出日時 | 2021-07-23 23:08:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,263 bytes |
コンパイル時間 | 231 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 64,304 KB |
最終ジャッジ日時 | 2024-10-12 11:46:20 |
合計ジャッジ時間 | 2,957 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 |
ソースコード
import sys from math import floor,sqrt sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) t = I() for _ in range(t): S,T = MI() U = 2*S**2 if U % T != 0 or T % 2 == 1: print(0) continue ANS = set() U //= T for d in range(1,int(U**(1/3))+1): if U % d == 0: c = T//2-d if c <= 0 or c > 10**9: break V = U//d p = T//2+d q = V+T//2*d if p**2-4*q < 0: continue a = floor((p-sqrt(p**2-4*q))//2) if 0 < a <= 10**9: b = p-a if 0 < b <= 10**9: if a*b == q: ans = [a,b,c] ans.sort() ANS.add(tuple(ans)) print(len(ANS)) for ans in ANS: a,b,c = ans print(a,b,c)