QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100

#8458. Counting Operation Sequences

Statistiques

There is a variable $i$, initially $i=1$.

There are two types of operations:

  1. $i=i+1$;
  2. $i=i \times k$.

Given $n$ and $k$, for all possible values of $L$, find the number of operation sequences such that the number of type 2 operations is exactly $L$, and after performing all operations, $i \le n$.

Input

The first line contains an integer $k$.

The second line contains an integer $n$.

Output

For all possible values of $L$, output the answer for each $L$ in increasing order, one per line.

Examples

Input 1

5
12

Output 1

12
11

Subtasks

For all data, $2 \le k \le 10$ and $1 \le n \le k^{50}$.

  • Subtask 1 (3 points): $n \le 10^6$;
  • Subtask 2 (10 points): $k=2$, $n \le 10^9$;
  • Subtask 3 (20 points): $k=2$;
  • Subtask 4 (20 points): $n \le 10^9$;
  • Subtask 5 (20 points): $n \le 10^{18}$;
  • Subtask 6 (27 points): No additional constraints.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.