http://lightoj.com/volume_showproblem.php?problem=1045
#include <iostream>
#include <stdio.h>
#include<math.h>
using namespace std;
double ary[1000010];
int main()
{
int i,test,j,base,num;
double res,sum=0;
for(i=1;i<=1000000;i++){
sum+=log10(i);
ary[i]=sum;
}
cin>>test;
for(j=1;j<=test;j++){
scanf("%d %d",&num,&base);
res=ary[num];
res=(res/log10(base))+1;
printf("Case %d: %d\n",j,(int)res);
}
return 0;
}
#include <iostream>
#include <stdio.h>
#include<math.h>
using namespace std;
double ary[1000010];
int main()
{
int i,test,j,base,num;
double res,sum=0;
for(i=1;i<=1000000;i++){
sum+=log10(i);
ary[i]=sum;
}
cin>>test;
for(j=1;j<=test;j++){
scanf("%d %d",&num,&base);
res=ary[num];
res=(res/log10(base))+1;
printf("Case %d: %d\n",j,(int)res);
}
return 0;
}