結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-23 22:45:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 330 ms / 2,000 ms |
| コード長 | 790 bytes |
| コンパイル時間 | 212 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 83,896 KB |
| 最終ジャッジ日時 | 2024-07-01 17:40:32 |
| 合計ジャッジ時間 | 2,990 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
def make_divisors(n):
lower_divisors, upper_divisors = [], []
i = 1
while i*i <= n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
upper_divisors.append(n//i)
i += 1
return lower_divisors + upper_divisors[::-1]
N = int(input())
res = set()
for x in range(N):
if x**2 > N:
break
Q = N + x**2
P = make_divisors(Q)
for a in P:
y = a-x
z = (Q//a)-x
if y >= 0 and z >= 0:
if x*y + y*z + z*x == N:
res.add((x, y, z))
res.add((x, z, y))
res.add((y, z, x))
res.add((y, x, z))
res.add((z, x, y))
res.add((z, y, x))
print(len(res))
for c in res:
print(*c)