結果
問題 | No.2358 xy+yz+zx=N |
ユーザー | Nikkuniku029 |
提出日時 | 2023-06-23 22:45:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 360 ms / 2,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 87,004 KB |
実行使用メモリ | 85,364 KB |
最終ジャッジ日時 | 2023-09-14 10:14:26 |
合計ジャッジ時間 | 3,659 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,508 KB |
testcase_01 | AC | 73 ms
71,500 KB |
testcase_02 | AC | 73 ms
71,452 KB |
testcase_03 | AC | 74 ms
71,340 KB |
testcase_04 | AC | 75 ms
71,312 KB |
testcase_05 | AC | 75 ms
71,524 KB |
testcase_06 | AC | 80 ms
75,596 KB |
testcase_07 | AC | 109 ms
77,720 KB |
testcase_08 | AC | 357 ms
84,340 KB |
testcase_09 | AC | 360 ms
85,364 KB |
testcase_10 | AC | 323 ms
80,476 KB |
testcase_11 | AC | 332 ms
81,900 KB |
testcase_12 | AC | 268 ms
78,380 KB |
ソースコード
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)