#P10895. 选择困难症

选择困难症

Background

Parviz believes that if a problem has a method that can significantly optimize the complexity but you do not use it, then the problem is “regretful”.

Alice believes that any problem whose algorithmic difficulty is greater than the difficulty of thinking is meaningless in an official contest.

Cat-cat believes that they are studying mathematics.

linyue\textsf{linyue} believes... Huh? What are you talking about?

What is very funny is that you might not be able to match these four names to the right people right away.

Problem Description

Besides playing chess, Alice and Bob also need some entertainment activities to relax, such as going to the snack street to eat. As a gentleman, Bob lets Alice choose which restaurant to eat at every time. This makes Alice troubled—she has indecisiveness.

There are nn restaurants on the snack street. Eating at the ii-th restaurant costs ii yuan. If the budget is aa yuan, then one can choose among the first aa restaurants.

After a long time of hesitation, Alice comes up with a method: she decides in advance a non-negative integer k<lcmi=1nik < \text{lcm}_{i=1}^{n} i. After learning the budget aa, she chooses to eat at the (k(k mod\text{mod} a)+1a)+1-th restaurant.

Because the market price of chessboards and pieces fluctuates, the budget for each meal may not be the same, but it is always an integer in [2,n][2,n]. Alice wants to change her taste each time, and hopes that for different aa, the final chosen restaurants are all different. She wants to know the number of kk that satisfy the requirement, but she is busy playing chess with Bob and has no time to compute it, so she asks you for help.

Formally, for a given nn, you need to find how many integers k[0,lcmi=1ni)k \in [0, \text{lcm}_{i=1}^{n}i) satisfy that kmod2,kmod3,...,kmodnk\bmod 2, k\bmod 3, ..., k\bmod n are all distinct. Output the answer modulo 998244353998244353.

Input Format

The first line contains an integer TT, indicating that there are TT test cases.

The next TT lines each contain an integer nn, whose meaning is given in the statement.

Output Format

Output TT lines. Each line contains an integer representing the number of kk that satisfy the requirement.

3
3
4
5
4
3
6
5
13860108
13850709
220000633
693439571
1004535809
188051653
724253523
444803502
370347248
425186012

Hint

Sample Explanation 1

When n=3,4n=3,4, the sets of possible values of kk are {2,3,4,5}\{2, 3, 4, 5\} and {3,10,11}\{3, 10, 11\}, respectively.

When n=5n=5:

kk kmod2k \bmod 2 kmod3k \bmod 3 kmod4k \bmod 4 kmod5k \bmod 5
2727 11 00 33 22
3434 00 11 22 44
3535 11 22 33 00
3939 00 44
5858 00 11 22 33
5959 11 22 33 44

lcmi=1ni=60\text{lcm}_{i=1}^{n}i=60. You can verify that there is no other kk in [0,60)[0,60) that satisfies the condition, so the answer is 66.

Test Point ID TT \leq nn \leq
121-2 1515
363-6 10001000 10001000
7127-12 2×1072 \times 10^7
132013-20 1515 2×1092 \times 10^9

For 100%100\% of the testdata, 3n2×1093 \leq n \leq 2 \times 10^9 and T1000T \leq 1000.

Translated by ChatGPT 5