結果

問題 No.144 エラトステネスのざる
ユーザー not_522not_522
提出日時 2015-07-28 07:52:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 146,100 KB
実行使用メモリ 7,184 KB
最終ジャッジ日時 2023-09-23 04:30:17
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 62 ms
7,004 KB
testcase_14 AC 79 ms
7,076 KB
testcase_15 AC 86 ms
7,184 KB
testcase_16 AC 83 ms
6,996 KB
testcase_17 AC 83 ms
6,904 KB
testcase_18 AC 84 ms
7,128 KB
testcase_19 AC 54 ms
7,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector<int> count_divisor(int n) {
  vector<int> c(n + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) ++c[j];
  }
  return c;
}

int main() {
  int n;
  double p, res = 0;
  cin >> n >> p;
  auto c = count_divisor(n);
  for (int i = 2; i <= n; ++i) res += pow(1 - p, c[i] - 2);
  cout << fixed << setprecision(15) << res << endl;
}
0