結果

問題 No.1593 Perfect Distance
ユーザー Taichi FujiiTaichi Fujii
提出日時 2021-07-09 23:44:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 77,228 KB
最終ジャッジ日時 2023-09-14 11:11:12
合計ジャッジ時間 3,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,196 KB
testcase_01 AC 70 ms
71,168 KB
testcase_02 AC 69 ms
71,312 KB
testcase_03 AC 69 ms
70,968 KB
testcase_04 AC 70 ms
71,268 KB
testcase_05 AC 68 ms
71,164 KB
testcase_06 AC 68 ms
71,112 KB
testcase_07 AC 76 ms
75,572 KB
testcase_08 AC 76 ms
75,596 KB
testcase_09 AC 92 ms
76,584 KB
testcase_10 AC 100 ms
76,432 KB
testcase_11 AC 111 ms
76,980 KB
testcase_12 AC 125 ms
77,228 KB
testcase_13 AC 136 ms
76,696 KB
testcase_14 AC 141 ms
77,004 KB
testcase_15 AC 194 ms
76,988 KB
testcase_16 AC 199 ms
76,864 KB
testcase_17 AC 69 ms
71,360 KB
testcase_18 AC 70 ms
71,368 KB
testcase_19 AC 69 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# author:  Taichicchi
# created: 09.07.2021 22:27:12

import sys


def bisearch(f, n):
    l = 0
    r = n
    fl = f(l)
    fr = f(r)
    while l <= r:
        m = (l + r) // 2
        fm = f(m)
        # print l,m,r,fl,fm,fr,n
        if fm == n:
            return m
        elif fm > n:
            r = m - 1
            fr = f(r)
        else:
            l = m + 1
            fl = f(l)


def try_square_root(n2):
    return bisearch(lambda n: n*n, n2)


N = int(input())

ans = 0
for x in range(1, N):
    y2 = pow(N, 2) - pow(x, 2)
    if try_square_root(y2):
        ans += 1

print(ans)
0