結果

問題 No.2358 xy+yz+zx=N
ユーザー ntuda
提出日時 2023-06-26 23:13:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 959 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 82,388 KB
最終ジャッジ日時 2024-07-03 18:16:46
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
x = 0
tmp = []
while 3 * x * x <= N:
    y = x
    if x == 0:
        y = 1
    while y * (2 * x + y) <= N:
        if (N - x * y) % (x + y) == 0:
            z = (N - x * y) // (x + y)
            if x <= y <= z:
                if x == y == z:
                    tmp.append((x, x, x))
                elif x == y:
                    tmp.append((x, x, z))
                    tmp.append((x, z, x))
                    tmp.append((z, x, x))
                elif y == z:
                    tmp.append((x, z, z))
                    tmp.append((z, x, z))
                    tmp.append((z, z, x))
                else:
                    tmp.append((x, y, z))
                    tmp.append((x, z, y))
                    tmp.append((y, x, z))
                    tmp.append((y, z, x))
                    tmp.append((z, x, y))
                    tmp.append((z, y, x))
        y += 1
    x += 1
print(len(tmp))
for t in tmp:
    print(*t)
0