結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2016-03-21 04:03:58 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 647 ms |
コンパイル使用メモリ | 75,184 KB |
実行使用メモリ | 11,284 KB |
最終ジャッジ日時 | 2024-10-01 12:14:16 |
合計ジャッジ時間 | 1,555 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <vector>#include <map>#include <algorithm>#include <limits.h>#include <time.h>#include <string>#include <string.h>#include <sstream>#include <set>#include <cstdio>#include <cstdlib>#include <cmath>#include <stack>#include <queue>using namespace std;typedef long long ll;int main(){int n;double p;cin >> n >> p;vector<double> list(n+1, 1.0);list[0] = 0.0;list[1] = 0.0;for(int i = 2; i <= n; i++){for(int j = 2*i; j <= n; j += i){list[j] *= (1.0 - p);}}double answer = 0.0;for(int i = 0; i <= n; i++){answer += list[i];}printf("%10.6f\n", answer);return 0;}