結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
7,364 KB
testcase_01 AC 33 ms
7,516 KB
testcase_02 WA -
testcase_03 AC 32 ms
7,512 KB
testcase_04 AC 33 ms
7,508 KB
testcase_05 AC 32 ms
7,444 KB
testcase_06 AC 32 ms
7,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 33 ms
7,492 KB
testcase_12 AC 33 ms
7,536 KB
testcase_13 AC 35 ms
7,408 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 34 ms
7,448 KB
testcase_19 AC 35 ms
7,368 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] *= (1 - p);
  }
}
double s = 0;
for (int i=2;i<=n;i++) {
s += a[i];
}
printf("%.9f\n", s);
}
0