問題一覧 > 通常問題

No.2349 Power!! (Hard)

レベル : / AI推定難易度 : 3000 / 実行時間制限 : 1ケース 7.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 6
作問者 : ytqm3 / テスター : 👑 Forested ぷら
お気に入りにしたユーザー ProblemId : 9695 / 自分の提出
問題文最終更新日: 2023-06-10 08:45:37
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 392 (順位表) の他の問題:

Problem Statement

Solve the following problem for $T$ cases.

Find the remainder when $\displaystyle \sum_{i=0}^{N-1} A^{i^2}$ is divided by $998244353$.

Input

$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$

Each case is given in the following format.

$A$ $N$
  • $1 \le T \le 2000$
  • $1 \le A,N \le 998244352$
  • All inputs are integers.

Output

Print $T$ lines. On the $i$-th line, print the answer for $\text{case}_i$.

Sample

Sample 1
Input
3
2 4
1 1
789454405 998244352
Output
531
1
253186705

For the $1$st case: $2^0+2^1+2^4+2^9=1+2+16+512=531$.

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