結果
問題 |
No.2358 xy+yz+zx=N
|
ユーザー |
![]() |
提出日時 | 2025-03-09 23:24:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 225 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 433 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 84,184 KB |
最終ジャッジ日時 | 2025-03-09 23:24:54 |
合計ジャッジ時間 | 3,680 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
from itertools import permutations def divisors(n: int) -> list[int]: """n の約数を求める""" s = set() p = 1 while p * p <= n: if n % p == 0: s.add(p) s.add(n // p) p += 1 return sorted(s) N = int(input()) s = set() for x in range(N+1): # x を規定 if 3*x*x > N: break m = N + x*x for d in divisors(m): x_plus_z = m // d z = x_plus_z - x y = d - x if x <= y <= z: s.add((x, y, z)) ans = set() for e in s: ans.update(permutations(e)) print(len(ans)) for a in ans: print(*a)