結果

問題 No.2358 xy+yz+zx=N
ユーザー meruuu61779999
提出日時 2023-06-24 00:27:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2024-07-01 17:44:20
合計ジャッジ時間 2,386 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from itertools import permutations

N = int(input())

max_x = math.isqrt(N // 3)
max_y = math.isqrt(N)
ans_set = set()


# ans_set にタプル(x,y,z)の並び替え6通りを登録する関数
def register(t: tuple):
    for p in permutations(range(3)):
        ans_set.add((t[p[0]], t[p[1]], t[p[2]]))


for x in range(max_x + 1):
    for y in range(x, max_y + 1):
        if x == y == 0:
            continue
        z, mod = divmod(N - x * y, x + y)
        if z < y:
            break
        if mod == 0:
            register((x, y, z))

print(len(ans_set))
for ans in ans_set:
    print(*ans)
0