結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2023-06-15 00:26:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 539 bytes |
コンパイル時間 | 2,736 ms |
コンパイル使用メモリ | 245,980 KB |
実行使用メモリ | 7,680 KB |
最終ジャッジ日時 | 2024-06-23 05:10:30 |
合計ジャッジ時間 | 3,687 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.hpp" #else #define debug(...) 1 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; double p; cin >> p; vector<int> cnt(n + 1, 1); for (int i = 2; i <= n; i++) { for (int j = i; j <= n; j += i) { cnt[j]++; } } double ans = 0; for (int i = 2; i <= n; i++) { ans += pow(1 - p, cnt[i] - 2); } cout << fixed << setprecision(15) << ans << '\n'; }