結果
| 問題 | No.144 エラトステネスのざる |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-15 00:26:43 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| + 879µs | |
| コード長 | 539 bytes |
| 記録 | |
| コンパイル時間 | 2,078 ms |
| コンパイル使用メモリ | 332,328 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2026-07-27 15:42:08 |
| 合計ジャッジ時間 | 3,649 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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';
}