結果

問題 No.144 エラトステネスのざる
ユーザー buey_t
提出日時 2022-12-12 00:40:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 668 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 96,112 KB
最終ジャッジ日時 2024-10-15 19:40:58
合計ジャッジ時間 5,983 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial
import heapq
import bisect
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations
from decimal import Decimal,ROUND_HALF_UP
from functools import lru_cache
import sys
sys.setrecursionlimit(10**8)

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

#2は扱いにくいから先に足しておく
ans = 1

for i in range(3, N+1):
    count = 0
    for j in range(2, int(sqrt(i))+1):
        if i%j == 0:
            count += 1
            #重複に注意
            if i//j != j:
                count += 1
    ans += (1-p)**count

print(ans)
0