結果
| 問題 | No.144 エラトステネスのざる |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-28 15:24:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 530 bytes |
| 記録 | |
| コンパイル時間 | 1,897 ms |
| コンパイル使用メモリ | 195,300 KB |
| 最終ジャッジ日時 | 2025-02-07 17:52:41 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int N; double p; cin >> N >> p;
// x が残る確率 = (1-p)^{約数の個数 - 2}
vector<int> div_cnt(N + 1, 0);
for(int i = 2; i <= N; i++)
for(int j = i * 2; j <= N; j += i) div_cnt[j]++;
double ans = 0;
for(int i = 2; i <= N; i++) ans += pow(1 - p, div_cnt[i]);
cout << fixed << setprecision(20) << ans << endl;
}