結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2020-02-08 19:49:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 775 bytes |
コンパイル時間 | 1,685 ms |
コンパイル使用メモリ | 168,740 KB |
実行使用メモリ | 19,148 KB |
最終ジャッジ日時 | 2024-09-25 11:58:59 |
合計ジャッジ時間 | 2,910 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<bits/stdc++.h>#include<unordered_set>#include<unordered_map>using namespace std;#define REP(i,m,n) for(int i=(m);i<(n);i++)#define rep(i,n) REP(i,0,n)#define pb push_back#define all(a) a.begin(),a.end()#define rall(c) (c).rbegin(),(c).rend()#define mp make_pair#define double long doubletypedef long long ll;typedef pair<int,int> pii;typedef pair<ll,ll> pll;const ll inf=1e9+7;const ll mod=1e9+7;int main(){ll n;cin>>n;double p;cin>>p;vector<double>dp(n+1);REP(i,2,n+1){ll j=i*2;while(j<=n){dp[j]+=p*(1.0-dp[j]);j+=i;}}double ans=0.0;REP(i,2,n+1){//cout<<i<<' '<<dp[i]<<endl;ans+=1.0-dp[i];}cout<<fixed<<setprecision(10)<<ans<<endl;}