#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;}; LL times(LL n, LL m) { LL ans = 1.1e18; for (LL p = 2; p * p <= 1e12+10; ++p) { LL cm = 0, col = 0; while (m % p == 0) ++cm, m /= p; if(cm == 0) continue; double check = m; for (LL cur = p; cur <= n && check <= n + 0.5; cur = cur * p, check = check * p) { col += n / cur; } ans = min(ans, col/cm); } if (1 != m) { LL cm = 1, col = 0; double check = m; for (LL cur = m; cur <= n && check <= n + 0.5; cur = cur * m, check = check * m) { col += n / cur; } ans = min(ans, col/cm); } return ans; } const double PI = acos(-1); int main() { LL n = scan(), m = scan(); 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 { long double lgans = log10(sqrt(2 * PI * n)) + (log10(n) - log10(exp(1))) * n; lgans -= times(n, m) * log10(m); LL flo = 1LL * lgans; lgans -= flo; printf("%.2fe%lld\n", (double)pow(10, lgans), flo); } }