結果

問題 No.2358 xy+yz+zx=N
ユーザー hir355hir355
提出日時 2023-06-23 22:23:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,079 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 83,444 KB
最終ジャッジ日時 2023-09-14 10:11:32
合計ジャッジ時間 2,812 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,408 KB
testcase_01 AC 72 ms
71,384 KB
testcase_02 AC 72 ms
71,240 KB
testcase_03 AC 72 ms
71,412 KB
testcase_04 AC 71 ms
71,468 KB
testcase_05 AC 71 ms
71,296 KB
testcase_06 AC 73 ms
71,304 KB
testcase_07 AC 90 ms
76,776 KB
testcase_08 AC 166 ms
82,724 KB
testcase_09 AC 170 ms
83,444 KB
testcase_10 AC 153 ms
79,520 KB
testcase_11 AC 156 ms
80,428 KB
testcase_12 AC 138 ms
78,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def devisors(n):
    d = []
    a = 1
    while a * a < n:
        if n % a == 0:
            d.append(a)
            d.append(n // a)
        a += 1
    if a * a == n:
        d.append(a)
    return d


n = int(input())
x = 0
ans = []
while x * x <= n:
    a = max(1, x * 2)
    nn = n + x * x
    while a * a < nn:
        if nn % a == 0:
            z = nn // a - x
            y = a - x
            if x == y:
                ans.append((x, y, z))
                ans.append((z, x, y))
                ans.append((x, z, y))
            else:
                ans.append((x, y, z))
                ans.append((y, x, z))
                ans.append((z, x, y))
                ans.append((z, y, x))
                ans.append((x, z, y))
                ans.append((y, z, x))
        a += 1
    if a * a == nn:
        z = a - x
        y = a - x
        if x == y:
            ans.append((x, y, z))
        else:
            ans.append((x, y, z))
            ans.append((y, x, z))
            ans.append((y, z, x))
    x += 1
print(len(ans))
for x, y, z in ans:
    print(x, y, z)
0