No.3355 Integer Part of a Logarithm
Problem Statement
You are given an integer $N$ greater than or equal to $2$ and a positive integer $M$.
Find $\lfloor \log_N M \rfloor$, the largest integer not exceeding $\log_N M$.
Input
The input is given from Standard Input on $1$ line in the following format:
- The $1$st line contains $N, M$ separated by a single space.
$N$ $M$
Constraints
The input satisfies the following constraints:
- $N$ is an integer satisfying $2 \leq N \leq 10^{18}$.
- $M$ is an integer satisfying $1 \leq M \leq 10^{18}$.
Output
Print $\lfloor \log_N M \rfloor$, the largest integer not exceeding $\log_N M$, on $1$ line.
End the output with a newline.
Sample
Sample 1
Input
2 1
Output
0
The largest integer not exceeding $\log_N M = \log_2 1 = 0$ is $0$.
Sample 2
Input
2 2
Output
1
The largest integer not exceeding $\log_N M = \log_2 2 = 1$ is $1$.
Sample 3
Input
3 2
Output
0
The largest integer not exceeding $\log_N M = \log_3 2 = 0.63 \cdots$ is $0$.
Sample 4
Input
10 10000000000
As in this case, the input may not fit in a 32-bit integer.
Output
10
The largest integer not exceeding $\log_N M = \log_{10} 10^{10} = 10$ is $10$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
hamamu