#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _MSC_VER #include #endif #define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define REV(v) v.rbegin(), v.rend() #define MEMSET(v, s) memset(v, s, sizeof(v)) #define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end()) #define MP make_pair #define MT make_tuple using namespace std; typedef long long ll; typedef long double ld; typedef pair P; const int N = 1e6 + 10; double dp[N]; int main(){ cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); int n; double p; cin >> n >> p; rep(i, n + 1) dp[i] = 1; for (int i = 2; i <= n; ++i){ if (dp[i] != 1) continue; for (int j = i * 2; j <= n; j += i){ int cnt = 0, x = j/i; while (x%i == 0) x /= i, ++cnt; if (!cnt) ++cnt; dp[j] *= pow(p, cnt); } } cout << accumulate(dp + 2, dp + n + 1, 0.0) << endl; }