luogu#P4931. [MtOI2018] 情侣?给我烧了!(加强版)

    ID: 3965 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>递推2018洛谷原创组合数学生成函数逆元

[MtOI2018] 情侣?给我烧了!(加强版)

Background

FFF.

Original version of this problem: P4921.

Problem Description

There are nn couples who come to a cinema to watch a movie. In the cinema, there are exactly nn rows of seats, and each row contains 22 seats, so there are 2n2n seats in total.

Now, everyone will randomly sit in one seat, and exactly all 2n2n seats will be occupied.

If a couple sits in the same row, then we call this couple harmonious.

Your task is to find how many different seating arrangements satisfy that exactly kk couples are harmonious.

Two seating arrangements are different if and only if there exists at least one person who sits in a different seat in the two arrangements. It is not hard to see that there are (2n)!(2n)! different seating arrangements in total.

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

Input Format

The input contains multiple test cases.

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

The next TT lines each contain two positive integers n,kn, k.

Output Format

Output TT lines.

For each test case, output one line containing one integer, the number of seating arrangements in which exactly kk couples are harmonious.

5
1 1
2 0
2 2
2333 666
2333333 1000000

2
16
8
798775522
300377435

Hint

Subtasks

For 10%10\% of the testdata, 1T101 \leq T \leq 10 and 1n51 \leq n \leq 5.

For 40%40\% of the testdata, 1n3×1031 \leq n \leq 3 \times 10^3.

For 100%100\% of the testdata, 1T2×1051 \leq T \leq 2 \times 10^5, 1n5×1061 \leq n \leq 5 \times 10^6, and 0kn0 \leq k \leq n.

Source

MtOI2018 迷途の家の水题大赛 T2 Enhanced Version.

Problem setter: Imagine.

Translated by ChatGPT 5