// Accepted
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#define sf scanf
#define pf printf
#define sfint scanf ("%d %d",&a,&b)
#define sfl scanf ("%ld %ld",&a,&b)
#define sfll scanf ("%lld %lld",&a,&b)
#define sfd scanf ("%lf %lf",&a,&b)
#define sff scanf ("%f %f",&a,&b)
#define loop(i,n) for(i=0;i<n;i++)
#define LL long long
#define L long
#define nl puts("")
#define MX 100005
#define N 10005
#define MOD 10000000007
#define pb push_back
#define pi acos(-1.0)
#define sz size()
#define gc getchar ()
#define ps push
#define clr clear
#define bn begin()
#define ed end()
using namespace std;
double arr[1000001]; LL len=1;
int main()
{
LL t,i;
double s=0;
for(i=1;i<1000001;i++)
{
s+=log10(i);
arr[len++] =s;
//arr[i]= double (log10(i));
}
LL data, base,tc=1; sf("%lld",&t);
while(t-- and tc++) {
sf("%lld %lld",&data,&base);
LL res = floor(arr[data]/log10(base)) + 1;
pf("Case %lld: %lld\n",tc-1,res);
}
return 0;
}
Comments
Post a Comment