結果

問題 No.144 エラトステネスのざる
ユーザー oxyshoweroxyshower
提出日時 2020-01-09 15:23:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 1,459 ms
コンパイル使用メモリ 164,900 KB
実行使用メモリ 10,996 KB
最終ジャッジ日時 2023-08-15 01:18:13
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 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,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 45 ms
10,844 KB
testcase_14 AC 46 ms
10,912 KB
testcase_15 AC 49 ms
10,996 KB
testcase_16 AC 46 ms
10,848 KB
testcase_17 AC 48 ms
10,984 KB
testcase_18 AC 47 ms
10,792 KB
testcase_19 AC 44 ms
10,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  double n, p; cin >> n >> p;
  vector<double> dp(n + 1, 1);
  for(int i = 2; i <= n; i++){
    for(int j = i+i; j <= n; j+=i){
      dp[j] *= (1.0 - p);
    }
  }

  double ans = 0;
  for(int i = 2; i <= n; i++){
    ans += dp[i];
  }
  printf("%.7f\n", ans);

  return 0;
}
0