問題一覧 > 通常問題

No.2818 A Game I Play to Pass the Time

レベル : / AI推定難易度 : 2150 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 19
作問者 : highlighter / テスター : hirayuu_yc Magentor Yoyoyo8128 warabi0906 silv723 fact493 zeta7532
お気に入りにしたユーザー ProblemId : 10878 / 自分の提出
問題文最終更新日: 2024-07-19 21:26:07
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 437 ('09 Contest 002 day2) (順位表) の他の問題:

Story

You do not necessarily need to read this section.

highlighter: "I'm bored... so bored... I know! Let's play that game!"

???: "The next problem is based on a very boring fun game that highlighter always plays when he is bored. If you have solved all the problems, please do pass the time with this game."

Problem Statement

Solve the following problem for $T$ test cases.

There is an integer sequence $C$ of length $S$ with all elements initialized to $0$. There is also a variable $X$. Initially, the value of $X$ is equal to $0$.

From here, highlighter performs the following sequence of operations any number of times.

  • Choose one positive integer $i$ satisfying $1 \leq i \leq S$, and add $1$ to $C_{i}$.
  • Add $\displaystyle\prod_{j \neq i} C_{j}$ to $X$.

Given that $X=N$ when the operations end, find the sum of $\displaystyle\sum_{i=1}^{S} C_{i}$ over all possible post-operation (added at 21:25) $C$. Since the answer can be very large, output it modulo $998244353$.

Constraints

  • $1 \leq T \leq 2 \times 10^{5}$
  • For each case,
    • all prime factors of $N$ are at most $100$
    • $1 \leq N \leq 10^{18}$
    • $2 \leq S \leq 10^{18}$
  • All inputs are integers

Input

The input is given from standard input in the following format. Here, $\mathrm{case}_{i}$ represents the $i$-th case.

$T$
$\mathrm{case}_{1}$
$\mathrm{case}_{2}$
$\vdots$
$\mathrm{case}_{T}$

Each case is given in the following format.

$N~~~S$

Output

Output $T$ lines. On the $i$-th line, output the answer for $\mathrm{case}_{i}$.

Sample

Sample 1
Input
3
3 3
1 2
1 998244353
Output
15
2
0
  • For case $1$, performing $5$ operations in the order $i=1,i=3,i=3,i=2,i=3$ results in $X=3$ at the end.
  • For case $3$, note that you must output the remainder modulo $998244353$.
  • 提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。