結果

問題 No.144 エラトステネスのざる
ユーザー cureskol
提出日時 2020-04-07 19:07:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 168,324 KB
実行使用メモリ 8,816 KB
最終ジャッジ日時 2024-07-07 21:42:19
合計ジャッジ時間 3,979 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int yaku[1234567];
using ld=long double;

signed main(){
  for(int i=2;i<1234567;i++)
    for(int j=i;j<1234567;j+=i)
      yaku[j]++;
  int n;ld p;cin>>n>>p;
  ld ans=0;
  for(int i=2;i<=n;i++)ans+=pow(1-p,yaku[i]-1);
  cout<<fixed<<setprecision(12)<<ans<<endl;
}
0