結果

問題 No.2358 xy+yz+zx=N
ユーザー FromBooskaFromBooska
提出日時 2024-03-21 18:46:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,640 KB
最終ジャッジ日時 2024-03-21 18:46:16
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 63 ms
71,332 KB
testcase_08 AC 200 ms
83,768 KB
testcase_09 AC 204 ms
84,640 KB
testcase_10 AC 207 ms
78,960 KB
testcase_11 AC 188 ms
79,924 KB
testcase_12 AC 153 ms
77,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 真ん中全探索、因数分解、約数列挙でACしたがテスター方法もやってみる
# sqrtNは小さいので二重ループ可能

N = int(input())
ans_set = set()
for y in range(0, N+1):
    if y**2 > N:
        break
    
    for x in range(0, y+1):
        if x+y>0:
            z = (N-x*y)//(x+y)
            if z>=0 and x*y+y*z+z*x == N:
                ans_set.add((x, y, z))
                ans_set.add((x, z, y))
                ans_set.add((y, x, z))
                ans_set.add((y, z, x))
                ans_set.add((z, x, y))
                ans_set.add((z, y, x))
            
print(len(ans_set))
for x, y, z in ans_set:
    print(x, y, z)
0