No.2007 Arbitrary Mod (Easy)
Problem Statement
Output the remainder when $a^n$ is divided by $M$.
$a$ and $n$ are given as input, but you may choose any $M$ you like. However, $M$ must be an integer satisfying $10^7 \le M \le 10^{18}$.
Input
$a\ n$
[Constraints]
- $a,\ n$ are integers
- $2 \le a \le 1000$
- $2 \le n \le 10^{18}$
Output
$M$ $ans$
On the $1$st line, output $M$. $M$ must be an integer satisfying $10^7 \le M \le 10^{18}$.
On the $2$nd line, output the answer to the problem $ans$, that is, the remainder when $a^n$ is divided by $M$.
Print a newline at the end.
You will get AC if, for the $M$ given on the $1$st line of your output, the remainder when $a^n$ is divided by $M$ matches the $ans$ given on the $2$nd line of your output.
Sample
Sample 1
Input
5 3
Output
998244353 125
You chose $998244353$ as your preferred $M$ and output it on the $1$st line.
You output $125$, the remainder when $5^{3} = 125$ is divided by $M$, on the $2$nd line.
Sample 2
Input
2 30
Output
10000000 3741824
You chose $M=10^7$ and output it on the $1$st line.
Since $2^{30} = 1073741824$, you can get AC by outputting $3741824$, the remainder when this is divided by $10^7$, on the $2$nd line.
Alternatively, for example, you can also get AC by outputting $1073741824$ on the $1$st line and $0$ on the $2$nd line.
Sample 3
Input
999 12345678987654321
Output
998244353 877641551
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Kiri8128
platinum