#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; /* Legendre's formula nを自然数、pを素数とするとき p^x | n! を満たす最大の非負整数xを返す。 時間 O(log(n)) 参考 https://en.wikipedia.org/wiki/Legendre%27s_formula */ long long LegendreFormula(long long n, long long p) { long long res = 0, d = p, a; while ((a = n / d) != 0) { res += a; d *= p; } return res; } /* スターリングの近似 log(n!)の近似 https://ja.wikipedia.org/wiki/%E3%82%B9%E3%82%BF%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0%E3%81%AE%E8%BF%91%E4%BC%BC */ double stirlingsApproximation(long long n) { return n * log(n) - n + 0.5*log(2 * M_PI*n) + 1.0 / (12.0*n); } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); ll n, m, p; cin >> n >> m; ll M = m; double x = stirlingsApproximation(n); ll divnum = LLONG_MAX; auto f = [&](ll p, int cnt) { smin(divnum, LegendreFormula(n, p) / cnt); }; for (p = 2; p*p <= m; ++p) { if (m%p == 0) { int cnt = 0; while (m%p == 0)m /= p, ++cnt; f(p, cnt); } } if (m != 1) { f(m, 1); } x -= divnum * log(M); double x10 = x / log(10.0); ll pw = (ll)x10; x10 -= pw; x = x10 * log(10); cout << exp(x) << 'e' << pw << endl; }