Envíos

2935 - Python Brute Force

Creado por Frank Arteaga Salgado
Adicionado por frankr (2014-06-08)
Límites
Tiempo Total: 50000 MS | Tiempo Caso: 8000 MS |Memoria: 62 MB | Salida límite (mb): 64 MB | Tamaño: 14 KB
Lenguajes activados
Disponible en

Descripción

Mr. Reni likes programming in Python language for solving or exploring the nature of math challenge. Python allows him to quickly write a brute force method and then test his conjectures. But this approach can sometimes be ineffective; however it may still be useful to test a better solution.

In this problem you have to write a program to calculate the number of digits of an integer S(N) in some base B where S(N) is given by:

S(N) = 1*1! + 2*2! + 3*3! + ... + N*N!

and let Mr. Reni codify the Brute Force in Python for you.

Note: K! means factorial(K) = 1 * 2 * 3 * ... * K.
Mr. Reni likes programming in Python language for solving or exploring the nature of math challenge. Python allows him to quickly write a brute force method and then test his conjectures. But this approach can sometimes be ineffective; however it may still be useful to test a better solution.

In this problem you have to write a program to calculate the number of digits of an integer S(N) in some base B where S(N) is given by:

S(N) = 1*1! + 2*2! + 3*3! + ... + N*N!

and let Mr. Reni codify the Brute Force in Python for you.

Note: K! means factorial(K) = 1 * 2 * 3 * ... * K.
Mr. Reni likes programming in Python language for solving or exploring the nature of math challenge. Python allows him to quickly write a brute force method and then test his conjectures. But this approach can sometimes be ineffective; however it may still be useful to test a better solution.

In this problem you have to write a program to calculate the number of digits of an integer S(N) in some base B where S(N) is given by:

S(N) = 1*1! + 2*2! + 3*3! + ... + N*N!

and let Mr. Reni codify the Brute Force in Python for you.

Note: K! means factorial(K) = 1 * 2 * 3 * ... * K.

Especificación de entrada

The first line of input contains an integer T (1 <= T <= 10^4), the number of test cases. Each test case contains two integers N and B (1 <= N <= 10^6; 2 <= B <= 10).
The first line of input contains an integer T (1 <= T <= 10^4), the number of test cases. Each test case contains two integers N and B (1 <= N <= 10^6; 2 <= B <= 10).
The first line of input contains an integer T (1 <= T <= 10^4), the number of test cases. Each test case contains two integers N and B (1 <= N <= 10^6; 2 <= B <= 10).

Especificación de salida

For each pair N and B in the input you must print the number of digits of S(N) in base B.
For each pair N and B in the input you must print the number of digits of S(N) in base B.
The first line of input contains an integer T (1 <= T <= 10^4), the number of test cases. Each test case contains two integers N and B (1 <= N <= 10^6; 2 <= B <= 10).

Ejemplo de entrada

3
3 4
2 2
3 10

Ejemplo de salida

3
3
2

Sugerencia(s)