結果

問題 No.144 エラトステネスのざる
ユーザー nohtaraynohtaray
提出日時 2019-11-18 14:17:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,836 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 50,112 KB
最終ジャッジ日時 2024-04-09 02:52:49
合計ジャッジ時間 21,270 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 535 ms
43,812 KB
testcase_01 AC 541 ms
43,668 KB
testcase_02 AC 535 ms
43,660 KB
testcase_03 AC 530 ms
43,560 KB
testcase_04 AC 527 ms
43,808 KB
testcase_05 AC 533 ms
43,752 KB
testcase_06 AC 545 ms
43,812 KB
testcase_07 AC 545 ms
43,812 KB
testcase_08 AC 535 ms
43,812 KB
testcase_09 AC 532 ms
43,920 KB
testcase_10 AC 538 ms
43,556 KB
testcase_11 AC 534 ms
43,820 KB
testcase_12 AC 532 ms
43,824 KB
testcase_13 AC 1,836 ms
50,112 KB
testcase_14 AC 1,819 ms
49,684 KB
testcase_15 AC 1,825 ms
49,276 KB
testcase_16 AC 1,829 ms
49,872 KB
testcase_17 AC 1,833 ms
49,824 KB
testcase_18 AC 1,830 ms
49,280 KB
testcase_19 AC 1,824 ms
49,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, P = list(map(float, sys.stdin.buffer.readline().split()))
N = int(N)

exp = np.ones(N + 1)
exp[0] = 0
exp[1] = 0

for n in range(2, N // 2 + 1):
    exp[n + n::n] *= 1 - P
print(exp.sum())
0