結果

問題 No.144 エラトステネスのざる
ユーザー umezoumezo
提出日時 2022-07-24 21:32:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 200,988 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2023-09-20 22:01:06
合計ジャッジ時間 3,374 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,948 KB
testcase_01 AC 6 ms
10,964 KB
testcase_02 AC 6 ms
11,044 KB
testcase_03 AC 5 ms
10,836 KB
testcase_04 AC 6 ms
10,884 KB
testcase_05 AC 6 ms
10,896 KB
testcase_06 AC 6 ms
10,832 KB
testcase_07 AC 6 ms
10,960 KB
testcase_08 AC 56 ms
10,880 KB
testcase_09 AC 6 ms
10,892 KB
testcase_10 AC 7 ms
10,888 KB
testcase_11 AC 6 ms
10,840 KB
testcase_12 AC 6 ms
10,900 KB
testcase_13 AC 33 ms
15,052 KB
testcase_14 AC 34 ms
14,740 KB
testcase_15 AC 84 ms
14,804 KB
testcase_16 AC 33 ms
15,056 KB
testcase_17 AC 34 ms
14,720 KB
testcase_18 AC 34 ms
15,104 KB
testcase_19 AC 33 ms
14,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  double p;
  cin>>n>>p;
  
  vector<double> D(1000100);
  D[0]=1.0;
  for(int i=1;i<1000100;i++) D[i]=D[i-1]*(1-p);
  
  vector<int> dp(n+1);
  for(int i=2;2*i<=n;i++){
    for(int j=2*i;j<=n;j+=i) dp[j]++;
  }
  double ans=0;
  for(int i=2;i<=n;i++) ans+=D[dp[i]];
  printf("%.10f\n",ans);
  
  return 0;
}
0