結果

問題 No.1593 Perfect Distance
ユーザー siro53siro53
提出日時 2021-07-10 10:59:36
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 76,644 KB
最終ジャッジ日時 2023-09-14 18:48:40
合計ジャッジ時間 3,130 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,288 KB
testcase_01 AC 73 ms
71,192 KB
testcase_02 AC 73 ms
71,372 KB
testcase_03 AC 73 ms
71,196 KB
testcase_04 AC 73 ms
71,104 KB
testcase_05 AC 73 ms
71,032 KB
testcase_06 AC 73 ms
71,288 KB
testcase_07 AC 78 ms
75,220 KB
testcase_08 AC 79 ms
75,336 KB
testcase_09 AC 89 ms
75,820 KB
testcase_10 AC 92 ms
76,160 KB
testcase_11 AC 102 ms
76,356 KB
testcase_12 AC 115 ms
76,044 KB
testcase_13 AC 120 ms
76,644 KB
testcase_14 AC 113 ms
76,376 KB
testcase_15 AC 148 ms
76,608 KB
testcase_16 AC 158 ms
76,240 KB
testcase_17 AC 73 ms
71,264 KB
testcase_18 AC 73 ms
71,392 KB
testcase_19 AC 74 ms
71,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_square(n):
    ok, ng = 0, n+1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if mid*mid <= n:
            ok = mid
        else:
            ng = mid
    
    return (ok * ok == n)

n = int(input())
ans = 0

for x in range(1, n):
    y2 = n*n - x*x
    if is_square(y2):
        ans += 1

print(ans)
0