結果

問題 No.1593 Perfect Distance
ユーザー Kiri8128Kiri8128
提出日時 2021-07-09 22:49:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 76,920 KB
最終ジャッジ日時 2023-09-14 10:26:39
合計ジャッジ時間 2,954 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,260 KB
testcase_01 AC 71 ms
71,248 KB
testcase_02 AC 72 ms
71,252 KB
testcase_03 AC 71 ms
71,336 KB
testcase_04 AC 72 ms
71,192 KB
testcase_05 AC 71 ms
71,456 KB
testcase_06 AC 74 ms
71,228 KB
testcase_07 AC 73 ms
71,068 KB
testcase_08 AC 79 ms
75,688 KB
testcase_09 AC 85 ms
76,340 KB
testcase_10 AC 88 ms
76,732 KB
testcase_11 AC 92 ms
76,820 KB
testcase_12 AC 97 ms
76,792 KB
testcase_13 AC 97 ms
76,824 KB
testcase_14 AC 101 ms
76,792 KB
testcase_15 AC 109 ms
76,920 KB
testcase_16 AC 110 ms
76,744 KB
testcase_17 AC 72 ms
71,316 KB
testcase_18 AC 71 ms
71,280 KB
testcase_19 AC 75 ms
71,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# C
def sqrt(n):
    if n == 0: return 0
    x = 1 << (n.bit_length() + 1) // 2
    y = (x + n // x) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

n = int(input())
N = n ** 2
ans = 0
for x in range(1, n):
    a = sqrt(N - x * x)
    if x ** 2 + a ** 2 == N:
        ans += 1
print(ans)
0