結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2020-12-25 10:56:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 2,132 ms |
コンパイル使用メモリ | 193,288 KB |
最終ジャッジ日時 | 2025-01-17 07:08:55 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; double P; cin >> P; vector<int> counts(N + 1, 0); for (int i = 1; i < N + 1; i++) { for (int j = i; j < N + 1; j += i) { counts[j]++; } } double res = 0; for (int i = 2; i < N + 1; i++) { res += pow(1 - P, counts[i] - 2); } cout << fixed << setprecision(10) << res << '\n'; return 0; }