//HowManyZerosAndDigits // no 10061 #include <iostream> using namespace std; #include <math.h> unsigned int factorial(const unsigned int &num) { unsigned int n = 1, factorialN = 1; while(n <= num) { factorialN *= n++; } return factorialN; } unsigned int main() { unsigned int N, B; unsigned int factorialN = 0; unsigned int zeroCount = 0, numCount = 0; while(cin >> N >> B) { factorialN = factorial(N); while(factorialN >= 1) { if(factorialN % B == 0) ++zeroCount; else ; ++numCount; factorialN /= B; } if(N == 0){ numCount = 0; zeroCount = 1; } cout << zeroCount << " " << numCount << endl; zeroCount = 0; numCount = 0; } return 0; }