結果

問題 No.144 エラトステネスのざる
ユーザー poet_nayutapoet_nayuta
提出日時 2018-08-19 17:32:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 300 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 49,620 KB
最終ジャッジ日時 2024-04-28 21:24:00
合計ジャッジ時間 12,328 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 538 ms
49,620 KB
testcase_01 AC 538 ms
43,860 KB
testcase_02 AC 541 ms
43,860 KB
testcase_03 AC 537 ms
44,116 KB
testcase_04 AC 540 ms
43,968 KB
testcase_05 AC 551 ms
43,864 KB
testcase_06 AC 541 ms
44,124 KB
testcase_07 AC 548 ms
43,992 KB
testcase_08 AC 541 ms
44,120 KB
testcase_09 AC 543 ms
43,868 KB
testcase_10 AC 539 ms
43,868 KB
testcase_11 AC 539 ms
43,996 KB
testcase_12 AC 543 ms
44,120 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

def solve(N, p):
    ps = np.ones(N+1)
    for i in range(2, (N+1)//2+1):
        if ps[i] < 1e-6:
            continue
        ind = np.arange((N+i)//i) * i
        ps[ind[2:]] *= (1 - p)
    return ps[2:].sum()

N, p = input().split()
N = int(N)
p = float(p)

print(solve(N, p))
0