結果

問題 No.144 エラトステネスのざる
ユーザー yamachaso55yamachaso55
提出日時 2021-05-20 19:26:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 197,080 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2024-04-18 14:07:21
合計ジャッジ時間 3,514 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 43 ms
7,476 KB
testcase_14 AC 51 ms
7,620 KB
testcase_15 AC 52 ms
7,592 KB
testcase_16 AC 51 ms
7,612 KB
testcase_17 AC 51 ms
7,680 KB
testcase_18 AC 53 ms
7,672 KB
testcase_19 AC 37 ms
7,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #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;
}
0