結果

問題 No.144 エラトステネスのざる
ユーザー cureskolcureskol
提出日時 2020-04-07 19:07:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 164,176 KB
実行使用メモリ 8,504 KB
最終ジャッジ日時 2023-09-22 04:59:21
合計ジャッジ時間 4,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
8,480 KB
testcase_01 AC 37 ms
8,364 KB
testcase_02 AC 37 ms
8,472 KB
testcase_03 AC 38 ms
8,392 KB
testcase_04 AC 37 ms
8,384 KB
testcase_05 AC 37 ms
8,420 KB
testcase_06 AC 38 ms
8,448 KB
testcase_07 AC 37 ms
8,392 KB
testcase_08 AC 38 ms
8,448 KB
testcase_09 AC 38 ms
8,348 KB
testcase_10 AC 38 ms
8,504 KB
testcase_11 AC 39 ms
8,392 KB
testcase_12 AC 38 ms
8,464 KB
testcase_13 AC 336 ms
8,496 KB
testcase_14 AC 343 ms
8,420 KB
testcase_15 AC 324 ms
8,344 KB
testcase_16 AC 320 ms
8,392 KB
testcase_17 AC 319 ms
8,464 KB
testcase_18 AC 338 ms
8,432 KB
testcase_19 AC 65 ms
8,416 KB
権限があれば一括ダウンロードができます

ソースコード

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