結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2015-02-06 00:23:31 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 60,372 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-06-23 09:03:18 |
合計ジャッジ時間 | 1,419 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <algorithm>#include <sstream>#include <cstdio>using namespace std;int main(int argc, char *argv[]){cout.precision(16);int N;double p;string s;getline(cin, s);stringstream ss(s);ss >> N >> p;static double tbl[1000001];for (int i = 2; i <= N; ++i) {tbl[i] = 1.0;}double ans = 0;for (int i = 2; i <= N; ++i) {for (int j = i * 2; j <= N; j += i) {tbl[j] *= (1.0 - p);}ans += tbl[i];}cout << ans << endl;return 0;}