結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2017-05-03 09:25:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 375 bytes |
コンパイル時間 | 1,479 ms |
コンパイル使用メモリ | 166,480 KB |
実行使用メモリ | 7,872 KB |
最終ジャッジ日時 | 2024-09-14 07:00:38 |
合計ジャッジ時間 | 2,553 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n,N) for(int i=(n);i<(int)N;i++)#define p(s) cout<<(s)<<endlusing namespace std;int cnt[1000010];void prime(int n){for(int i=2;i<=n;i++){for(int j=i*2;j<=n;j+=i){cnt[j]++;}}}int main(){int N;double p;cin>>N>>p;prime(N);double ans=0;REP(i,2,N+1)ans+=pow((1-p),cnt[i]);printf("%.7lf",ans);return 0;}