結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2021-08-08 14:33:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 1,564 ms |
コンパイル使用メモリ | 171,424 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-09-19 10:51:06 |
合計ジャッジ時間 | 2,719 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
//#include <atcoder/all>#include <bits/stdc++.h>#include <cmath>using namespace std;//using namespace atcoder;using ll = long long;#define all(A) A.begin(),A.end()using vll = vector<ll>;#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)using Graph = vector<vector<ll>>;Graph G;vll E;vector<bool> seen;int main() {ll N;double p;cin>>N>>p;vector<ll> D(N+5,0);for(ll i=2;i<N;i++){for(ll j=i*2;j<=N;j+=i){D[j]++;}}double an=0;vector<double> pp(10001,1);rep(i,10000){pp[i+1]=pp[i]*(1-p);}for(ll i=2;i<=N;i++){an+=pp[D[i]];}cout<<setprecision(16)<<an<<endl;}