問題一覧 > 通常問題

No.1580 I like Logarithm!

レベル : / AI推定難易度 : 950 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 133
作問者 : magsta / テスター : maguro
お気に入りにしたユーザー ProblemId : 5053 / 自分の提出
問題文最終更新日: 2021-07-02 19:05:32
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 302 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。