結果

問題 No.144 エラトステネスのざる
ユーザー pentapenta
提出日時 2020-06-04 08:37:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 1,467 ms
コンパイル使用メモリ 169,504 KB
実行使用メモリ 7,100 KB
最終ジャッジ日時 2023-08-18 15:56:02
合計ジャッジ時間 4,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 313 ms
6,976 KB
testcase_14 AC 314 ms
7,040 KB
testcase_15 AC 296 ms
7,092 KB
testcase_16 AC 296 ms
7,020 KB
testcase_17 AC 299 ms
7,100 KB
testcase_18 AC 313 ms
7,088 KB
testcase_19 AC 53 ms
7,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i != 0) continue;
    res.emplace_back(i);
    if (i*i != n) res.emplace_back(n/i);
  }
  return res;
}


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  long double p, ans = 0.0;
  cin >> n >> p;
  vector<int> div(n+1,0);
  for (int i = 2; i <= n; ++i) {
    for (int k = 0; k <= n; k+=i) {
      div[k]++;
    }
    ans += powl(1-p, div[i]-1);
  }
  cout << ans << endl;
  return 0;
}
0