基础数论,取个log即可
可以用Stirling公式,我是打的表
#include <cstdio>
#include <cmath>
double fac[1000005] = {0, 0};
void init()
{
for(int i = 2; i <= 1000000; i++)
fac[i] = log(i) + fac[i - 1];
}
int main()
{
int T;
scanf("%d", &T);
init();
for(int ca = 1; ca <= T; ca++)
{
int n, base;
scanf("%d%d", &n, &base);
printf("Case %d: %d\n", ca, 1 + (int)(fac[n] / log(base)));
}
return 0;
}