結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-12 06:22:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 347 bytes |
| コンパイル時間 | 1,356 ms |
| コンパイル使用メモリ | 157,788 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-06-23 19:02:48 |
| 合計ジャッジ時間 | 2,281 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double safe[1000010];
int main(){
int N; cin >> N;
double p; cin >> p;
fill(begin(safe), end(safe), 1);
for(int d=2;d<=N;d++)
for(int n=2*d;n<=N;n+=d)
safe[n] *= 1 - p;
double res = 0;
for(int n=2;n<=N;n++)
res += safe[n];
printf("%.10f\n", res);
return 0;
}