#include #include #include #include #include #include using namespace std; int main() { int n; double p; cin >> n >> p; vector isPrime(n + 1, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i <= n; i++) { if (isPrime[i]) { for (int j = i * 2; j <= n; j += i) { isPrime[j] = false; } } } vector primes(n, 0); int n_p = 0; for (int i = 0; i < n; i++) { if (isPrime[i]) { primes[n_p] = i; n_p++; } } vector divisor(n + 1, 0); divisor[1] = 1; int div, tmp, idx; for (int i = 2; i <= n; i++) { if (isPrime[i]) { divisor[i] = 2; } else { for (int j = 0; j < n_p; j++) { if (i % primes[j] == 0) { tmp = i; while (tmp % primes[j] == 0) { tmp /= primes[j]; } divisor[i] = divisor[i / primes[j]] + divisor[tmp]; break; } } } } double ans = 0.0; for (int i = 2; i <= n; i++) { ans += pow(1.0 - p, divisor[i] - 2); } cout << ans << endl; return 0; }