#P7451. [THUSC 2017] 杜老师

    ID: 6434 远端评测题 5000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2017分治线性基块状链表,块状数组,分块

[THUSC 2017] 杜老师

Description

Teacher Du is a man who wants to compete in the World Final for ++∞ years. Although the rules do not allow it, they can be changed!

But this year, WF is very close in time to THUSC, so he came up with an idea and then just left it alone...

Given L,RL, R, among the RL+1R-L+1 numbers from LL to RR, find how many different subsets can be chosen such that the product of all numbers in the subset is a perfect square. In particular, the empty set is also considered a valid choice, and its product is defined as 11.

Teacher Du is busy competing in ACM contests together with Teacher Chen and Teacher \cang\ , so can you help Teacher Du write the standard solution?

Input Format

Read input from standard input.

Each test point contains multiple groups of testdata.

The first line contains a positive integer TT (1T1001\le T\le 100), which is the number of testdata groups.

The next TT lines: the (i+1)(i+1)-th line contains two positive integers Li,RiL_i, R_i, representing L,RL, R of the ii-th group of testdata, and it is guaranteed that LiRi107\le L_i\le R_i\le10^7.

Output Format

Write output to standard output.

Output TT lines, each containing one non-negative integer, representing the total number of subsets that satisfy the condition. Output the answer modulo 998244353998244353.

3
1 8
12 24
1 1000000
16
16
947158782
6
3761870 4957871
2262774 4279409
3027437 5896884
3884310 5021632
3373244 5464739
5063504 5368121
953622420
551347610
583188135
582472626
190680894
268824018

Hint

For L=1,R=8L=1, R=8, the corresponding 1616 choices are:

  1. Empty set.
  2. 44.
  3. 3,6,83,6,8.
  4. 3,4,6,83,4,6,8.
  5. 2,82,8.
  6. 2,4,82,4,8.
  7. 2,3,62,3,6.
  8. 2,3,4,62,3,4,6.
  9. 11.
  10. 1,41,4.
  11. 1,3,6,81,3,6,8.
  12. 1,3,4,6,81,3,4,6,8.
  13. 1,2,81,2,8.
  14. 1,2,4,81,2,4,8.
  15. 1,2,3,61,2,3,6.
  16. 1,2,3,4,61,2,3,4,6.
Test Point Id\operatorname*{Id} RiR_i\le TT\le RiLi+1\sum R_i-L_i+1\le Special Constraints
1~2 3030 1010 10310^3 None.
3 100100 Guaranteed that the answer does not exceed 5×1065\times 10^6.
4 None.
5~6 10310^3 RL22R-L\le22.
7~8 Guaranteed that the answer does not exceed 2×1062\times 10^6.
9~10 5×1035\times10^3 None.
11~12 10610^6 10710^7 RL999990R-L\ge999990.
13~14 None.
15~20 10710^7 100100 (Id14)×107(\operatorname*{Id}-14)\times 10^7

Translated by ChatGPT 5