結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2021-05-20 19:26:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 993 bytes |
コンパイル時間 | 1,794 ms |
コンパイル使用メモリ | 194,976 KB |
最終ジャッジ日時 | 2025-01-21 13:59:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
// #define _GLIBCXX_DEBUG#include <bits/stdc++.h>// #include <atcoder/all> // g++ main.cpp -std=c++17 -I .using namespace std;// using namespace atcoder;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define all(v) v.begin(), v.end()template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}using ll=long long;const int inf = INT_MAX / 2; const ll INF = 1LL << 60;const int MOD = 1000000007;// cout << fixed << setprecision(15) << ans << endl;// using mint = modint1000000007;////////////////////////////////////////////////////////////////////////////////////////////int main() {int n;double p;cin>>n>>p;vector<int> v(n+1);double ans = 0;for(int i = 2; i <= n; i++) {for(int j = i; j <= n; j += i) {v[j]++;}ans += pow(1-p, v[i]-1);}cout << fixed << setprecision(15) << ans << endl;return 0;}