結果

問題 No.144 エラトステネスのざる
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-01 00:10:57
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 249 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 77,896 KB
実行使用メモリ 94,532 KB
最終ジャッジ日時 2023-09-19 04:46:17
合計ジャッジ時間 5,230 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
92,984 KB
testcase_01 AC 90 ms
93,048 KB
testcase_02 AC 90 ms
93,168 KB
testcase_03 AC 89 ms
92,992 KB
testcase_04 AC 91 ms
92,984 KB
testcase_05 AC 91 ms
92,728 KB
testcase_06 AC 100 ms
94,052 KB
testcase_07 AC 97 ms
94,364 KB
testcase_08 AC 97 ms
94,264 KB
testcase_09 AC 95 ms
94,496 KB
testcase_10 AC 97 ms
94,212 KB
testcase_11 AC 98 ms
94,372 KB
testcase_12 AC 97 ms
94,320 KB
testcase_13 AC 250 ms
94,000 KB
testcase_14 AC 247 ms
94,244 KB
testcase_15 AC 255 ms
94,184 KB
testcase_16 AC 243 ms
94,532 KB
testcase_17 AC 252 ms
94,184 KB
testcase_18 AC 249 ms
94,256 KB
testcase_19 AC 244 ms
94,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,P=raw_input().split()
N=int(N)
P=float(P)
isPrime=[1.0 for i in xrange(1000001)]
isPrime[0]=0
isPrime[1]=0
ans=0
for i in range(2,N+1):
    #print i,isPrime[i]
    ans+=isPrime[i]
    for j in range(i+i,N+1,i):
        isPrime[j]*=(1-P)
print ans
0