#include using namespace std; #ifdef LOCAL #include "debug.hpp" #else #define debug(...) 1 #endif vector sieve(int n) { vector min_factor(n + 1); for (int i = 1; i <= n; i++) { min_factor[i] = i; } for (int i = 2; i * i <= n; i++) { if (min_factor[i] == i) { for (int j = i + i; j <= n; j += i) { if (min_factor[j] > i) { min_factor[j] = i; } } } } return min_factor; } map factor(vector &min_factor, int m) { map ret; while (m > 1) { ret[min_factor[m]]++; m /= min_factor[m]; } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; auto v = sieve(n); double p; cin >> p; double ans = 0; for (int i = 2; i <= n; i++) { auto mp = factor(v, i); int cnt = 1; for (auto [x, y] : mp) { cnt *= (y + 1); } ans += pow(1 - p, cnt - 2); } cout << fixed << setprecision(15) << ans << '\n'; }