結果
問題 |
No.2358 xy+yz+zx=N
|
ユーザー |
![]() |
提出日時 | 2025-03-09 21:59:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 966 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 82,580 KB |
実行使用メモリ | 63,340 KB |
最終ジャッジ日時 | 2025-03-09 21:59:19 |
合計ジャッジ時間 | 5,737 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 5 TLE * 1 -- * 4 |
ソースコード
from itertools import count, permutations def distinct_permutations(a: list): # -> Generator[list, None, None]: n = len(a) xs = a.copy() while 1: yield xs p = -1 for i in range(n-1): if xs[i] < xs[i+1]: p = i if p == -1: return q = -1 for i in range(p+1, n): if xs[p] < xs[i]: q = i xs[p], xs[q] = xs[q], xs[p] xs[p+1:] = reversed(xs[p+1:]) N = int(input()) s = set() if N == 1: s.add((0, 1, 1)) for x in range(N+1): if 3*x*x > N: break for y in range(x, N+1): if x*x + y*y + y*x > N: break for z in range(y, N+1): if x == 0 and y == 0: break t = x*y + y*z + z*x if t > N: break if t == N: s.add((x, y, z)) ans = [] for e in s: #for xs in distinct_permutations(list(e)): print(1) print(len(ans)) for a in ans: print(*a)