結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2019-01-29 01:57:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 522 bytes |
コンパイル時間 | 1,501 ms |
コンパイル使用メモリ | 168,360 KB |
実行使用メモリ | 7,836 KB |
最終ジャッジ日時 | 2024-10-07 14:45:30 |
合計ジャッジ時間 | 19,458 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 7 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; double p; cin >> p; vector<int> a(n); for (int i = 2; i <= n; i++) { int x = i; int c = 0; for (int j = 1; j * j <= x; j++) { if (x % j == 0) { if (x / j == j) c++; else c += 2; } } a[i] = c; } double ans = 0; for (int i = 2; i <= n; i++) { ans += pow(1.0 - p, a[i] - 2); } cout << setprecision(20) << fixed << ans << '\n'; return 0; }