結果

問題 No.1593 Perfect Distance
ユーザー 👑 Kiri8128Kiri8128
提出日時 2021-07-09 22:44:33
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 255 ms
使用メモリ 81,412 KB
最終ジャッジ日時 2023-02-02 00:47:13
合計ジャッジ時間 2,985 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 68 ms
75,496 KB
testcase_01 AC 69 ms
75,768 KB
testcase_02 AC 69 ms
75,832 KB
testcase_03 AC 67 ms
75,496 KB
testcase_04 AC 68 ms
75,764 KB
testcase_05 AC 68 ms
75,772 KB
testcase_06 AC 67 ms
75,552 KB
testcase_07 AC 68 ms
75,872 KB
testcase_08 AC 74 ms
80,232 KB
testcase_09 AC 81 ms
80,592 KB
testcase_10 AC 81 ms
80,940 KB
testcase_11 AC 88 ms
81,412 KB
testcase_12 AC 94 ms
81,336 KB
testcase_13 AC 95 ms
81,000 KB
testcase_14 AC 96 ms
81,180 KB
testcase_15 AC 101 ms
80,888 KB
testcase_16 AC 108 ms
80,976 KB
testcase_17 AC 69 ms
75,804 KB
testcase_18 AC 68 ms
75,772 KB
testcase_19 AC 69 ms
75,816 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