結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2020-11-28 23:59:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 2,825 ms |
コンパイル使用メモリ | 193,320 KB |
最終ジャッジ日時 | 2025-01-16 10:01:25 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>#define REP(i, s, n) for (int i = s; i < (int)(n); i++)#define ALL(a) a.begin(), a.end()#define MOD 1000000007using namespace std;using ll = long long;int main() {int N; double P; cin >> N >> P;vector<int> divisor(N + 1, 0); double ans = 0;REP(i, 2, N + 1) {for (int j = i + i; j <= N; j += i) {divisor[j]++;}ans += pow(1 - P, divisor[i]);}cout << fixed << setprecision(15);cout << ans << endl;return 0;}