#ifdef __APPLE__ #include "bits:stdc++.h" #else #include #endif using namespace std; typedef long long LL; typedef pair PLL; auto scan = []{ static LL a; scanf("%lld", &a); return a;}; const double PI = acos(-1); int main() { LL n = scan(), m = scan(), N = n; vector ps; for (LL p = 2; p * p <= 1e6+10; ++p) if(N % p == 0) { LL time = 0; while (N % p == 0) ++time, N /= p; ps.push_back({p,time}); } if (N != 1) ps.push_back({N, 1}); if (n <= 10) { LL ans = 1; for (LL i = 1; i <= n; ++i) ans *= i; while (ans % m == 0) ans /= m; double lgans = log10(ans); LL flo = (LL) lgans; lgans -= flo; printf("%.2fe%lld\n",pow(10,lgans),flo); } else { double lgans = log10(sqrt(2 * PI * n)) + (log10(n) - log10(exp(1))) * n; LL div = 1.1e18; //printf("%.4E\n",lgans); for (PLL E: ps) { LL p = E.first, t = E.second; double check = p; LL thdiv = 0; for (LL cur = p; cur <= n && check <= n + 0.5; cur = cur * p, check = check * p) thdiv += n / cur; div = min(div, thdiv / t); } lgans -= log10(pow(m, div)); LL flo = 1LL * lgans; lgans -= flo; printf("%.2fe%lld\n",pow(10, lgans),flo); } }