結果
| 問題 | No.1626 三角形の構築 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-02-11 04:46:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 255 ms / 2,000 ms |
| コード長 | 1,201 bytes |
| 記録 | |
| コンパイル時間 | 3,279 ms |
| コンパイル使用メモリ | 81,876 KB |
| 実行使用メモリ | 77,356 KB |
| 最終ジャッジ日時 | 2026-02-11 04:46:41 |
| 合計ジャッジ時間 | 12,326 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
import sys
input = sys.stdin.readline
from collections import Counter
def fact(x):
sq=round(x**(0.5))
F=Counter()
for i in range(2,sq+1):
while x%i==0:
F[i]+=1
x//=i
if x>1:
F[x]+=1
return F
t=int(input())
for tests in range(t):
S,s=list(map(int,input().split()))
if s%2==1:
print(0)
continue
k=s//2
if S*S%k!=0:
print(0)
continue
u=S*S//k
F=fact(S)
kf=fact(k)
for c in F:
F[c]*=2
for c in kf:
F[c]-=kf[c]
#print(F)
LIST=[1]
for f in F:
LIST2=[]
c=F[f]
for l in LIST:
for i in range(1,c+1):
if l*f**i<k:
LIST2.append(l*f**i)
LIST+=LIST2
#print(LIST)
SET=set(LIST)
LIST.sort()
ANS=[]
for i in range(len(LIST)):
x=LIST[i]
for j in range(i,len(LIST)):
y=LIST[j]
z=k-x-y
if x*y*z==u and z>=y and z in SET:
ANS.append((x+y,y+z,z+x))
print(len(ANS))
for ans in ANS:
print(*ans)
titia