#P7451. [THUSC 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 , among the numbers from to , 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 .
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 (), which is the number of testdata groups.
The next lines: the -th line contains two positive integers , representing of the -th group of testdata, and it is guaranteed that .
Output Format
Write output to standard output.
Output lines, each containing one non-negative integer, representing the total number of subsets that satisfy the condition. Output the answer modulo .
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 , the corresponding choices are:
- Empty set.
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
| Test Point | Special Constraints | |||
|---|---|---|---|---|
| 1~2 | None. | |||
| 3 | Guaranteed that the answer does not exceed . | |||
| 4 | None. | |||
| 5~6 | . | |||
| 7~8 | Guaranteed that the answer does not exceed . | |||
| 9~10 | None. | |||
| 11~12 | . | |||
| 13~14 | None. | |||
| 15~20 |
Translated by ChatGPT 5
京公网安备 11011102002149号