結果

問題 No.144 エラトステネスのざる
ユーザー maspymaspy
提出日時 2020-01-01 19:17:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 41,260 KB
最終ジャッジ日時 2023-08-14 17:03:02
合計ジャッジ時間 5,567 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
29,848 KB
testcase_01 AC 107 ms
29,740 KB
testcase_02 AC 104 ms
29,672 KB
testcase_03 AC 103 ms
29,780 KB
testcase_04 AC 105 ms
29,796 KB
testcase_05 AC 104 ms
29,856 KB
testcase_06 AC 104 ms
29,772 KB
testcase_07 AC 104 ms
29,848 KB
testcase_08 AC 105 ms
29,856 KB
testcase_09 AC 104 ms
29,724 KB
testcase_10 AC 106 ms
29,748 KB
testcase_11 AC 106 ms
29,752 KB
testcase_12 AC 105 ms
29,756 KB
testcase_13 AC 130 ms
41,108 KB
testcase_14 AC 133 ms
41,260 KB
testcase_15 AC 135 ms
41,180 KB
testcase_16 AC 134 ms
41,212 KB
testcase_17 AC 135 ms
41,232 KB
testcase_18 AC 135 ms
41,260 KB
testcase_19 AC 134 ms
41,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,p = read().split()
N = int(N); p = float(p)

div_cnt = np.zeros(N+1,np.int32)

for x in range(1,int(N**.5)+10):
    if x * x > N:
        break
    div_cnt[x*x] += 1
    div_cnt[x*(x+1):N+1:x] += 2

div_cnt -= 2

counter = np.bincount(div_cnt[2:])

answer = sum((1-p) ** i * x for i,x in enumerate(counter))
print(answer)
0