#P6043. 「ACOI2020」修学旅行

    ID: 6662 远端评测题 1000~5000ms 128MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学2020倍增O2优化快速傅里叶变换 FFT快速数论变换 NTT

「ACOI2020」修学旅行

Background

T5

Not long after the first semester begins, everyone in Class E is going on a study trip.

Problem Description

Now, six people—Akabane Karma, Sugino Tomohito, Okuda Manami, Kayano Kaede, Kanzaki Yukiko, and Shiota Nagisa—form a group. They will go on an assassination trip in Kyoto. Their goal is still to snipe and kill their teacher. The government has also sent a professional sniper, "Akame no Eye". While completing the mission, they want the happiness value to be as large as possible.

The clever Kanzaki Yukiko (Kanzaki Yukiko) finally worked out the expression for the happiness value. Shockingly, the happiness value is actually related to the number of sightseeing spots in the trip and the number of times they assassinate their teacher.

Suppose they pass through nn sightseeing spots and assassinate their teacher mm times, and define:

$$\Gamma(a,b)=\left\{ \begin{aligned} & 1,a>b&\\ & \prod_{i=a}^b i,a \le b&\\ \end{aligned} \right.$$

Then the happiness value is:

$$\sum_{i=0}^m \lgroup \frac{\sqrt{\sum_{j=0}^i (C_i^j)^2C_{n+2i-j}^{2i}}}{\Gamma(n+1,n+i)} \times \Gamma(n-i+1,n) \rgroup$$

We guarantee that $\frac{\sqrt{\sum_{j=0}^i (C_i^j)^2C_{n+2i-j}^{2i}}}{\Gamma(n+1,n+i)} \times \Gamma(n-i+1,n)$ is an integer.

Now they have TT questions to ask you. If they pass through nn sightseeing spots and assassinate their teacher mm times, can you tell them the happiness value?

Since the answer may be very large, output the answer modulo 998244353998244353.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT, the number of test cases.

For each test case:

There is only one line with two integers nn and mm.

Output Format

For each test case, output one line containing one integer: the happiness value modulo 998244353998244353 when they pass through nn sightseeing spots and assassinate their teacher mm times.

The sample has been updated.

5
5 3
7 3
9 6
100 50
44 22


26
64
466
41441083
461961723

Hint

Constraints

This problem uses bundled testdata.

  • Subtask 1 (10 points): T10T \leq 10, n,m10n,m \leq 10.
  • Subtask 2 (20 points): T100T \leq 100, n,m5×104n,m \leq 5 \times 10^4.
  • Subtask 3 (30 points): T50T \leq 50, n,m9×108n,m \leq 9 \times 10^8.
  • Subtask 4 (40 points): No special constraints on the testdata.

For 100%100\% of the testdata, mnm \leq n, 1T1021 \leq T \le 10^2, 1n,m9×1081 \leq n,m \leq 9 \times 10^8.


Notes

The time limit is 2 s for the test points in the third subtask, and 5 s for the test points in the fourth subtask.

Translated by ChatGPT 5