結果

問題 No.2358 xy+yz+zx=N
ユーザー meruuu61779999meruuu61779999
提出日時 2023-06-24 00:27:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 83,760 KB
最終ジャッジ日時 2023-09-14 10:17:20
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,804 KB
testcase_01 AC 76 ms
71,332 KB
testcase_02 AC 76 ms
71,592 KB
testcase_03 AC 73 ms
71,552 KB
testcase_04 AC 72 ms
71,340 KB
testcase_05 AC 71 ms
71,308 KB
testcase_06 AC 74 ms
71,404 KB
testcase_07 AC 97 ms
76,872 KB
testcase_08 AC 227 ms
83,108 KB
testcase_09 AC 230 ms
83,760 KB
testcase_10 AC 207 ms
80,352 KB
testcase_11 AC 207 ms
80,688 KB
testcase_12 AC 180 ms
78,836 KB
権限があれば一括ダウンロードができます

ソースコード

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