結果

問題 No.2358 xy+yz+zx=N
ユーザー rlangevinrlangevin
提出日時 2023-06-23 22:19:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 87,084 KB
最終ジャッジ日時 2023-09-14 10:10:27
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,400 KB
testcase_01 AC 70 ms
71,148 KB
testcase_02 AC 71 ms
71,564 KB
testcase_03 AC 69 ms
71,492 KB
testcase_04 AC 70 ms
71,224 KB
testcase_05 AC 70 ms
71,484 KB
testcase_06 AC 75 ms
75,628 KB
testcase_07 AC 104 ms
78,288 KB
testcase_08 AC 249 ms
86,124 KB
testcase_09 AC 252 ms
87,084 KB
testcase_10 AC 229 ms
81,144 KB
testcase_11 AC 230 ms
82,356 KB
testcase_12 AC 195 ms
78,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *

def div(n):
    if n <= 0:
        return []
    S = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            S.add(i)
            S.add(n // i)
        i += 1
    return list(S)


N = int(input())
x = 0
ans = []
while 3 * x * x <= N:
    for d in div(N + x ** 2):
        y = d - x
        z = (N + x**2)//d - x
        if y < x or z < x or z < y:
            continue
        ans.append((x, y, z))
    x += 1
    
S = set()
for a in ans:
    for x, y, z in permutations(a):
        S.add((x, y, z))
        
print(len(S))
for x, y, z in S:
    print(x, y, z)
0