結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,356 KB
testcase_01 AC 72 ms
71,324 KB
testcase_02 AC 74 ms
71,500 KB
testcase_03 AC 75 ms
71,308 KB
testcase_04 AC 75 ms
71,148 KB
testcase_05 AC 74 ms
71,380 KB
testcase_06 AC 75 ms
71,472 KB
testcase_07 AC 93 ms
76,536 KB
testcase_08 AC 178 ms
83,032 KB
testcase_09 AC 181 ms
83,832 KB
testcase_10 AC 164 ms
79,168 KB
testcase_11 AC 167 ms
79,848 KB
testcase_12 AC 147 ms
78,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
ans = []
for x in range(N+1):
    if 3*x*x > N:
        break
    for y in range(x, N+1):
        if x*y+y*y+y*x > N:
            break
        if y==0:
            continue
        if (N-x*y)%(x+y)==0:
            z=(N-x*y)//(x+y)
            if x == y == z:
                ans.append((x, y, z))
            elif x == y:
                ans.append((x, y, z))
                ans.append((x, z, y))
                ans.append((z, x, y))
            elif y == z:
                ans.append((x, y, z))
                ans.append((y, x, z))
                ans.append((y, z, x))
            else:
                ans.append((x, y, z))
                ans.append((x, z, y))
                ans.append((y, x, z))
                ans.append((y, z, x))
                ans.append((z, x, y))
                ans.append((z, y, x))
print(len(ans))
for a in ans:
    print(*a)
0