結果

問題 No.2358 xy+yz+zx=N
ユーザー yabityabit
提出日時 2023-07-07 12:24:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 83,556 KB
最終ジャッジ日時 2023-09-28 12:50:06
合計ジャッジ時間 4,004 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,476 KB
testcase_01 AC 72 ms
71,736 KB
testcase_02 AC 73 ms
71,760 KB
testcase_03 AC 77 ms
71,472 KB
testcase_04 AC 73 ms
71,168 KB
testcase_05 AC 73 ms
71,552 KB
testcase_06 AC 79 ms
75,652 KB
testcase_07 AC 103 ms
77,700 KB
testcase_08 AC 258 ms
82,856 KB
testcase_09 AC 260 ms
83,556 KB
testcase_10 AC 230 ms
80,016 KB
testcase_11 AC 235 ms
80,856 KB
testcase_12 AC 197 ms
78,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
def make_divisors_pairs(n): #約数のペアを作る O(sqrt(n))
    divisors = []
    i = 1
    while i*i <= n:
        if n % i == 0:
            divisors.append([i,n//i])
        i += 1
    return divisors

N = int(input())
ans = set()
for x in range(int((N/3)**(1/2))+10):
    for p, q in make_divisors_pairs(N+x*x):
        if p-x >= 0 and q-x >= 0:
            for per in permutations((x, p-x, q-x)):
                ans.add(per)
print(len(ans))
for a in ans:
    print(*a)
0