結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,236 KB
testcase_01 AC 73 ms
71,440 KB
testcase_02 AC 74 ms
71,400 KB
testcase_03 AC 73 ms
71,360 KB
testcase_04 AC 72 ms
71,264 KB
testcase_05 AC 71 ms
71,324 KB
testcase_06 AC 78 ms
76,016 KB
testcase_07 AC 98 ms
76,852 KB
testcase_08 AC 377 ms
82,380 KB
testcase_09 AC 380 ms
82,520 KB
testcase_10 AC 367 ms
78,912 KB
testcase_11 AC 367 ms
79,404 KB
testcase_12 AC 306 ms
78,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

ans = []


### x < y < z
for x in range(N):
    for y in range(x+1,N+1):
        if 2*x*y + y*y > N:
            break

        n = N - x*y
        if n%(x+y):
            continue
        z = n // (x+y)
        if z <= y:
            continue
        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])


### x = y ,z

for x in range(1,N+1):
    
    n = N - x**2

    if n < 0 or n%(x+x):
        continue

    z = n // (x+x)

    if z == x:
        ans.append([x,x,x])
    else:
        ans.append([x,x,z])
        ans.append([x,z,x])
        ans.append([z,x,x])


print(len(ans))
for x,y,z in ans:
    print(x,y,z)
0