#P17231. [Math×Girl²] 染色⁴

    ID: 19727 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>交互题Special JudgeO2优化

[Math×Girl²] 染色⁴

Background

Problem Description

You are given a ka×kb×kc×kdka\times kb\times kc\times kd four-dimensional grid, where each cell can only be black or white.
How many coloring schemes are there such that, in every k×k×k×kk\times k\times k\times k subgrid, there are exactly 11 black cell?

Since the answer may be very large, you only need to output the result modulo 998244353998244353.

Input Format

The first line contains an integer TT, the number of test cases.
The next TT lines each contain five integers k,a,b,c,dk,a,b,c,d, and it is guaranteed that a≤b≤c≤da\le b\le c\le d.

Output Format

Output TT lines, each containing one integer: the number of schemes modulo 998244353998244353.

1
3 2 2 2 2
744944653

Hint

Sample Explanation

See Coloring³ for details.

Constraints and Notes

Test Point Score kk dd Special Property
11 k=1k=1 -
22 44 - d=2d=2 (a,b,c)=(2,2,2)(a,b,c)=(2,2,2)
33 55 d≤20d\le20 ^
44 k=2k=2 -
55 1010 -
66 55 k=2k=2 (a,b,c)=(2,2,3)(a,b,c)=(2,2,3)
77 1010 - ^
88 55 k=2k=2 (a,b,c)=(2,2,4)(a,b,c)=(2,2,4)
99 1010 k=3k=3 ^
1010 k=2k=2 (a,b,c)=(2,2,5)(a,b,c)=(2,2,5)
1111 (a,b,c)=(2,2,6)(a,b,c)=(2,2,6)
1212 55 (a,b,c)=(2,3,3)(a,b,c)=(2,3,3)
1313 1010 (a,b,c)=(2,3,4)(a,b,c)=(2,3,4)
1414 (a,b,c)=(3,3,3)(a,b,c)=(3,3,3)

For 100%100\% of the testdata: 1≤T≤31\le T\le3, 1≤k<9982443531\le k<998244353, 2≤a≤b≤c≤d≤10182\le a\le b\le c\le d\le 10^{18}.
To prevent you from “cheating the testdata”, such as by looking at the returned results or using binary search to recover the input.
Therefore, this problem uses a Special Judge, and each evaluation uses random testdata.
Later I was reminded that the Special Judge can directly remove returned information, and the data you get is useless anyway. I’m an idiot.

It is guaranteed that each test point can be finished within 5ms5\text{ms}, see the judge records. I was still too kind.

Translated by ChatGPT 5