結果

問題 No.144 エラトステネスのざる
ユーザー knewknowl
提出日時 2015-02-08 16:20:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 331 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 54,936 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-23 11:00:34
合計ジャッジ時間 2,137 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
using namespace std;
double tbl[100010];
int main(){
  int n;
  double p;
  cin >> n >> p;
  for(int i=2;i<=n;++i) tbl[i] = 1.0;
  double s = 0;
  for(int i=2;i*2<=n;++i){
    for(int j=2;i*j<=n;++j) tbl[i*j]*=1-p;
  }
  for(int i=2;i<=n;++i) s+=tbl[i];
  printf("%.10lf\n",s);

  return 0;
}
0