問題一覧 > 通常問題

No.1049 Zero (Exhaust)

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 255
作問者 : stoq / テスター : tran0826
お気に入りにしたユーザー ProblemId : 4094 / 自分の提出
問題文最終更新日: 2020-05-30 02:17:19
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 247 (順位表) の他の問題:

Problem Statement

O-kun has an integer $N$. Initially, $N=0$.
Each time, O-kun chooses one of the following operations (1) and (2) and performs it. He repeats this $K$ times. Here, $P$ is a prime number.

(1) Choose one integer $i \ (0 \leq i \leq P-1)$. Then replace $N$ with the remainder of $N+i$ divided by $P$.
(2) Choose one integer $i \ (0 \leq i \leq P-1)$. Then replace $N$ with the remainder of $N \times i$ divided by $P$.

How many sequences of operations result in $N=0$ again after the $K$ operations? Find the total number of such sequences of operations, modulo $10^9+7$.
Here, two sequences of operations are considered different if there exists some $i \ (1 \leq i \leq K)$ such that the $i$-th operations differ (that is, they differ in whether (1) or (2) is used, or in the value added/multiplied).

Input

$P\ K$

$P$ is a prime number
$K$ is an integer
$1 \leq P \leq 10^9$
$1 \leq K \leq 10^6$

Output

Output the number of sequences of operations satisfying the condition, modulo $10^9+7$. Print a newline at the end.

Sample

Sample 1
Input
3 1
Output
4

The following 4 operations (sequences) satisfy the condition.
・Add 0.
・Multiply by 0.
・Multiply by 1.
・Multiply by 2.

Sample 2
Input
2 2
Output
11

Sample 3
Input
5 10
Output
334032363

Note that you must output the remainder modulo $10^9+7$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。