Envíos

2935 - Python Brute Force

Criado por Frank Arteaga Salgado
Adicionado por frankr (2014-06-08)
Límiteis
Tempo Total: 50000 MS | Tempo Caso: 8000 MS |Memória: 62 MB | Saída límite (mb): 64 MB | Tamanho: 14 KB
Lenguagens activados
Disponivel em

Descripção

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.

Especificação 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).

Especificação de saída

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).

Exemplo de entrada

3
3 4
2 2
3 10

Exemplo de saída

3
3
2

Sugestões(s)