結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2024-11-30 22:40:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 842 ms |
コンパイル使用メモリ | 78,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-30 22:40:14 |
合計ジャッジ時間 | 2,364 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <vector> #include <math.h> #include <iostream> #include <algorithm> using namespace std; #define rep(i, S, E) for(int i=(S); i<=(E); i++) int main() { int N; double p; cin >> N >> p; p = 1 - p; vector<double> M; M.resize(N+1, 1); double answer = 0; rep(i, 2, N){ answer += M[i]; for(int j=2; i*j<=N; j++){ M[i*j] *= p; } } printf("%.10f", answer); return 0; }