結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2020-02-23 05:49:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 2,157 bytes |
コンパイル時間 | 1,400 ms |
コンパイル使用メモリ | 103,040 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-10-10 01:33:21 |
合計ジャッジ時間 | 2,557 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#pragma GCC optimize("Ofast") #include <cstdio> #include <cstdlib> #include <string> #include <algorithm> #include <iostream> #include <queue> #include <vector> #include <bitset> #include <cmath> #include <limits> #include <iostream> #include <map> #include <set> #include <tuple> #include <iomanip> #include <functional> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;} template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;} #define bit(n,k) ( (n>>k)&1 ) //デバッグ template<class T> void Vout(vector<T> &V){ cout<<"\nstart\n"; const int sz=V.size(); for(int i=0;i<sz;i++){ cout<<i<<" "<<V[i]<<'\n'; } cout<<"end\n"<<endl; } template<class T> void VPout(vector<T> &V){ cout<<"\nstart\n"; const int sz=V.size(); for(int i=0;i<sz;i++){ cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n'; } cout<<"end\n"<<endl; } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ constexpr int MAX=1<<30; constexpr ll INF=1LL<<62; constexpr int MOD=1e9+7; int dx[]={1,-1,0,0},dy[]={0,0,-1,1}; //__builtin_popcount(S); //#define int ll //vector<vector<int>> data(3, vector<int>(4)); //vector.resize(a,vector<int>(b,-1)); //vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値))); signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout<<fixed<<setprecision(10); int N; double p; cin>>N>>p; double ret=0; vector<double> ans(N+1,1); for(int i=2;i<=N;i++){ ret+=ans[i]; for(int j=i*2;j<=N;j+=i){ ans[j]*=(1-p); } } cout<<ret<<endl; }