| Teamscode Summer 2023 Contest |
|---|
| Finished |
For a given integer $$$n$$$, find the number of palindromic sequences of positive integers with a sum of $$$n$$$ that contains at least one occurrence of the number $$$k$$$. Output the answer modulo $$$p$$$, where $$$p$$$ is given in the input.
Each test contains multiple testcases. The first line contains the number of testcases $$$t$$$ ($$$1\leq t\leq 10^6$$$). This is followed by $$$t$$$ lines — the description of the testcases.
Each line contains three integers $$$n$$$, $$$k$$$, and $$$p$$$ ($$$1\leq k\leq n\leq 10^6$$$,$$$10^8\leq p\leq 2\cdot 10^9$$$) — the sum of the sequence, the required number, and the number to take the answer modulo of, respectively. The number $$$p$$$ is guaranteed to be a prime.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.
—
Testcases in subtasks are numbered $$$1$$$ to $$$20$$$ with samples skipped.
Test $$$1-10$$$: The sum of $$$n$$$ does not exceed $$$5\cdot 10^3$$$.
Test $$$6-20$$$: No additional constraints.
Each test is worth $$$5$$$ points with samples skipped.
For each test case, print one integer — the desired value modulo $$$p$$$.
48 2 99824435312 12 199999994310 4 59253806942 2 100000007
9 1 7 1999923
For the first sample, $$$[2,2,2,2]$$$, $$$[3,2,3]$$$, and $$$[1,1,2,2,1,1]$$$ are examples of sequences that work. Sequences that do not work include $$$[2,3,2]$$$, $$$[3,3,3]$$$, $$$[2,3,1,1,1]$$$, and $$$[4,4]$$$.
— Problem Idea: dutin Problem Preparation: dutin Occurrences: Novice 7, Advanced 3
| Name |
|---|


