結果

問題 No.144 エラトステネスのざる
ユーザー maspy
提出日時 2020-01-01 19:17:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 568 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 55,860 KB
最終ジャッジ日時 2024-11-22 16:03:20
合計ジャッジ時間 12,276 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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