結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2015-07-28 07:52:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 1,139 ms |
コンパイル使用メモリ | 160,320 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-07-16 04:36:04 |
合計ジャッジ時間 | 2,299 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<int> count_divisor(int n) { vector<int> c(n + 1); for (int i = 1; i <= n; ++i) { for (int j = i; j <= n; j += i) ++c[j]; } return c; } int main() { int n; double p, res = 0; cin >> n >> p; auto c = count_divisor(n); for (int i = 2; i <= n; ++i) res += pow(1 - p, c[i] - 2); cout << fixed << setprecision(15) << res << endl; }