#include <math.h>
double num[1000001];
int main() {
int test,i, n, b;
for(n = 1; n < 1000001; n++){
num[n] = log(n) + num[n-1];}
scanf("%d", &test);
for(i= 1; i <= test; i++) {
scanf("%d %d", &n, &b);
printf("Case %d: %.0lf\n",i, floor(num[n]/log(b)) + 1.0);
}
return 0;
}
No comments:
Post a Comment