結果

問題 No.2358 xy+yz+zx=N
ユーザー ryohei22ryohei22
提出日時 2023-06-23 23:34:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 84,068 KB
最終ジャッジ日時 2023-09-14 10:16:22
合計ジャッジ時間 3,101 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,784 KB
testcase_01 AC 75 ms
71,944 KB
testcase_02 AC 77 ms
71,832 KB
testcase_03 AC 74 ms
71,260 KB
testcase_04 AC 76 ms
71,616 KB
testcase_05 AC 73 ms
71,916 KB
testcase_06 AC 74 ms
71,688 KB
testcase_07 AC 102 ms
77,372 KB
testcase_08 AC 232 ms
83,008 KB
testcase_09 AC 234 ms
84,068 KB
testcase_10 AC 212 ms
80,224 KB
testcase_11 AC 214 ms
81,172 KB
testcase_12 AC 183 ms
78,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations


N = int(input())

ans = set()
for x in range(int(N**(1/2))+1):
    for y in range(x, int(N**(1/2))+1):
        if x == y == 0:
            continue
        if (N - x * y) % (x + y) == 0:
            z = (N - x * y) // (x + y)
            if x <= y <= z:
                l = len(set([x, y, z]))
                if l == 1:
                    ans.add((x, y, z))
                elif l == 2:
                    ans.add((x, y, z))
                    ans.add((y, z, x))
                    ans.add((z, x, y))
                else:  # l == 3
                    for i in permutations([x, y, z]):
                        ans.add(tuple(i))
print(len(ans))
for i in ans:
    print(*i)
0