結果

問題 No.144 エラトステネスのざる
ユーザー koba-e964koba-e964
提出日時 2015-06-11 22:34:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 341 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 143,796 KB
実行使用メモリ 7,548 KB
最終ジャッジ日時 2023-09-20 20:58:26
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
7,540 KB
testcase_01 AC 36 ms
7,428 KB
testcase_02 WA -
testcase_03 AC 35 ms
7,548 KB
testcase_04 AC 35 ms
7,484 KB
testcase_05 AC 35 ms
7,364 KB
testcase_06 AC 35 ms
7,472 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 35 ms
7,432 KB
testcase_12 AC 35 ms
7,544 KB
testcase_13 AC 37 ms
7,544 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 37 ms
7,408 KB
testcase_19 AC 37 ms
7,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int N=1e6 + 10;
int a[N];
int main(){
int n; double p; cin >>n>>p;
a[0] = a[1] = 0;
for(int i=2;i<N;i++)a[i]=1;
for (int i = 2; i < N; i++) {
  for (int j = i * 2; j < N; j += i) {
    a[j] *= a[i] * (1 - p);
  }
}
double s = 0;
for (int i=2;i<=n;i++) {
s += a[i];
}
printf("%.9f\n", s);
}
0