#P8356. 「WHOI-1」数列计数
「WHOI-1」数列计数
Background
No longer having it, the sequence stays with me.
Problem Description
This kind of sequence satisfies the following magical property:
- .
- , we have or .
- .
Find the number of such . Output the answer modulo .
Two sequences are different if and only if there exists an index where the stored element is different.
Input Format
One input file contains multiple test cases.
The first line contains a positive integer , the number of test cases.
The next lines describe the test cases. For each test case, one line contains four positive integers, denoting .
Output Format
Output lines, each line containing one non-negative integer, representing the answer for that test case.
3
3 3 1 2
11 45 14 19
9876 10 114514 191981
2
1688
426554662
Hint
Sample #1:
Such are .
Sample #2 and #3:
The originally cute Otm has already written tens of thousands of pages of sample explanations, but the even cuter miku deleted them, so Otm does not want to write them again.
This problem uses the scoring method. You can get the score of a only if you pass all test cases in that .
| ID | Special Constraints | Score |
|---|---|---|
| 1 | 10 | |
| 2 | 30 | |
| 3 | are coprime | 10 |
| 4 | None | 50 |
For all testdata, , , . All inputs are positive integers.
Translated by ChatGPT 5