結果

問題 No.144 エラトステネスのざる
ユーザー ktshunktshun
提出日時 2015-06-10 12:27:01
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 309 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 6,584 KB
実行使用メモリ 18,276 KB
最終ジャッジ日時 2023-09-20 20:31:16
合計ジャッジ時間 4,840 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,468 KB
testcase_01 AC 11 ms
5,984 KB
testcase_02 AC 11 ms
6,140 KB
testcase_03 AC 11 ms
5,888 KB
testcase_04 AC 11 ms
6,032 KB
testcase_05 AC 11 ms
5,988 KB
testcase_06 AC 13 ms
5,844 KB
testcase_07 AC 13 ms
6,420 KB
testcase_08 AC 13 ms
6,220 KB
testcase_09 AC 13 ms
6,236 KB
testcase_10 AC 14 ms
6,212 KB
testcase_11 AC 13 ms
6,212 KB
testcase_12 AC 13 ms
6,008 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding:utf-8 -*-

if __name__ == "__main__":
	n,p = map(float,raw_input().split())
	n = int(n)
	a = [0 for i in xrange(n+1)]
	for i in xrange(2,n+1):
		k = i * 2
		while k <= n:
			a[k] += 1
			k+=i
	ans = 0
	for i in xrange(2,n+1):
		if a[i] == 0:
			ans += 1
		else:
			ans += pow(1-p,a[i])
	print ans
0