結果

問題 No.144 エラトステネスのざる
ユーザー yaoshimax
提出日時 2015-05-01 00:21:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 313 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 55,152 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-07-05 17:16:41
合計ジャッジ時間 1,428 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
   int N; double p;
   cin >> N >> p;
   double P[N+1];
   for(int i=2;i<=N;i++)P[i]=1.0;
   double ans=0;
   for(int i=2;i<=N;i++){
      ans+=P[i];
      for( int j=i+i; j<=N; j+=i ){
         P[j]*=(1-p);
      }
   }
   cout << ans << endl;
   return 0;
}
0