結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2021-04-04 05:58:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 2,436 bytes |
コンパイル時間 | 6,802 ms |
コンパイル使用メモリ | 251,132 KB |
最終ジャッジ日時 | 2025-01-20 10:57:02 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll=long long;using ld=long double;using vb=vector<bool>;using vvb=vector<vb>;using vd=vector<double>;using vvd=vector<vd>;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using pii=pair<int,int>;using pll=pair<ll,ll>;using vpll=vector<pll>;using tll=tuple<ll,ll>;using tlll=tuple<ll,ll,ll>;using vs=vector<string>;#define all(a) a.begin(),a.end()#define rall(a) a.rbegin(),a.rend()#define rep(i,n) range(i,0,n)#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)#define range(i,a,n) for(ll i=(a);i<(n);i++)#define sz(x) (int)(x).size()#define LINF ((ll)1ll<<60)#define INF ((int)1<<30)#define EPS (1e-9)#define MOD (1000000007ll)//#define MOD (998244353ll)#define fcout(a) cout<<setprecision(a)<<fixed#define fs first#define sc second#define PI 3.1415926535897932384int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}template<class S>S max(vector<S>&a){return *max_element(all(a));}template<class S>S min(vector<S>&a){return *min_element(all(a));}void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}void yn(bool b){cout<<(b?"yes":"no")<<"\n";}int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0 : sgn(a)>0int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0int popcnt(int x){return __builtin_popcount(x);}int popcnt(ll x){return __builtin_popcountll(x);}ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}template<class T>void puta(T&&t){cout<<t<<"\n";}template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;}template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}int main(){cin.tie(0);ios::sync_with_stdio(false);ll n;double p,ans=0;cin>>n>>p;vl v(n+1);vd mul(1000);mul[0]=1;rep(i,999)mul[i+1]=mul[i]*(1-p);for(ll i=2;i<=n;i++){for(ll j=i+i;j<=n;j+=i){v[j]++;}ans+=mul[v[i]];}fcout(8)<<ans<<endl;}