No.1580 I like Logarithm!
Problem Statement
You are given an integer $A$ satisfying $2 \leq A \leq 10$, and an integer $B$ written in base $A$.
Find $\displaystyle \sum_{k=1}^B \lfloor \log_A k \rfloor$ modulo $10^9+7$.
Note: $\lfloor x \rfloor$ denotes the integer part of $x$.
Input
$A$ $B$
- $2 \leq A \leq 10$
- $\displaystyle 1 \leq B < A^{10^5}$
- $B$ is written in base $A$
- The first character of $B$ is not $0$
- All inputs are integers
Output
Output the value you found, followed by a newline.
Sample
Sample 1
Input
3 101
Output
10
You need to find $\displaystyle \sum_{k=1}^{10} \lfloor \log_3 k \rfloor$.
$\displaystyle \sum_{k=1}^{10} \lfloor \log_3 k \rfloor = \sum_{k=1}^2 \lfloor \log_3 k \rfloor + \sum_{k=3}^8 \lfloor \log_3 k \rfloor + \sum_{k=9}^{10} \lfloor \log_3 k \rfloor = 0 \times 2 + 1 \times 6 + 2 \times 2 = 10$
Sample 2
Input
5 3
Output
0
The answer may be $0$.
Sample 3
Input
9 723280082373276788237831270873218023778028108321832138003218732
Output
248642342
$B$ may not fit in a 64-bit integer.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
magsta
maguro