~cpp
// no10061 - How many zeros and how many digits?
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double N; // number
double B; // base
double i;
double nDigit; // how many digits?
int nZero; // how many zeros?
double temp;
double backTemp;
while (cin >> N >> B)
{
nZero = 0;
nDigit = 0.0;
backTemp = 1;
for (i=2; i<=N; i++)
{
nDigit += log(i) / log(B);
temp = backTemp * i;
while (true)
{
nZero++;
temp = int(temp/B);
}
backTemp = int(i);
}
cout << nZero << " " << int(nDigit) + 1 << endl;
}
return 0;
}