結果

問題 No.1593 Perfect Distance
ユーザー Kiri8128Kiri8128
提出日時 2021-07-09 22:44:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 86,764 KB
実行使用メモリ 76,980 KB
最終ジャッジ日時 2023-09-14 10:23:36
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,020 KB
testcase_01 AC 72 ms
71,516 KB
testcase_02 AC 71 ms
71,520 KB
testcase_03 AC 71 ms
71,212 KB
testcase_04 AC 71 ms
71,328 KB
testcase_05 AC 71 ms
71,212 KB
testcase_06 AC 70 ms
71,400 KB
testcase_07 AC 70 ms
71,348 KB
testcase_08 AC 75 ms
75,408 KB
testcase_09 AC 85 ms
76,628 KB
testcase_10 AC 86 ms
76,888 KB
testcase_11 AC 91 ms
76,980 KB
testcase_12 AC 97 ms
76,944 KB
testcase_13 AC 99 ms
76,740 KB
testcase_14 AC 99 ms
76,788 KB
testcase_15 AC 105 ms
76,908 KB
testcase_16 AC 110 ms
76,900 KB
testcase_17 AC 70 ms
71,416 KB
testcase_18 AC 71 ms
71,336 KB
testcase_19 AC 69 ms
71,416 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