luogu#P5014. 水の三角(修改版)
水の三角(修改版)
Background
This triangular diagram looks really nice.

This is a -order triangular diagram.
Problem Description
Now we define a triangular diagram as shown above.
Please find the number of ways to walk from node to node in an infinitely large triangular diagram.
There are queries.
Input Format
The first line contains a positive integer .
The second line contains positive integers .
Output Format
Output lines, each containing a positive integer, which is the answer modulo .
3
1 3 6
1
2
6
Hint
: .
: .
: $1 \leq T \leq 100, \qquad 1 \leq u_i \leq 500000500000, \qquad u_i=\frac{x \times (x + 1)}{2}$.
: $1 \leq T \leq 100, \qquad 1 \leq u_i \leq 500000500000$.
Translated by ChatGPT 5