問題一覧 > 通常問題

No.2011 Arbitrary Mod (Hidden)

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 60
作問者 : Kiri8128 / テスター : platinum
お気に入りにしたユーザー ProblemId : 8031 / 自分の提出
問題文最終更新日: 2022-05-07 02:02:00
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 352 (順位表) の他の問題:

Problem Statement

Output the remainder when $(a^2-398)^{2^n}$ is divided by $M$.

...Oops, for various reasons, $a$ and $M$ will not be given in the input. $a$ is determined in advance, but you may choose $M$ as you like. However, $M$ must be an integer satisfying $10^7 \le M \le 10^{18}$.


Note that exponentiation is evaluated from the top. That is, $x^{y^z} = x^{(y^z)}$ (it is not $(x^y)^z$).

Input

$n$

[Constraints]

  • $a,\ n$ are integers
  • $20\le a\le 5000$
  • $100\le n \le 10^9$
Note that $a$ is determined in advance for each test case, but it is not given in the input.

Output

$M$
$ans$

On line $1$, output $M$. $M$ must be an integer satisfying $10^7 \le M \le 10^{18}$.
On line $2$, output the answer $ans$ to the problem, that is, the remainder when $(a^2-398)^{2^n}$ is divided by $M$.
Print a newline at the end.

For the $a$ determined in advance for each test case and the $M$ given on line $1$ of the output, you get AC if the remainder when $(a^2-398)^{2^n}$ is divided by $M$ matches the $ans$ given on line $2$ of the output.

Sample

Sample 1
This is a small case for explanation, so it does not satisfy the constraint $100 \le n \le 10^9$. It is also not included in the actual test cases.
Moreover, even if the constraints were relaxed, this output would not necessarily get AC, as described below.
Input
1
Output
998244353
4

You chose $998244353$ as $M$. $a$ is not given in the input, but if $a=20$ in this case, the value to find is $4$, the remainder when $(20^2-398)^{2^1}=2^2=4$ is divided by $998244353$. This matches your output on line $2$, so it is correct.
Note that if, for example, $a=21$, the value to find would be $1849$, and the output would be incorrect.

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