#P1707. Contest Practice Statistics
Contest Practice Statistics
Contest Practice Statistics
Three friends, nodgd, Ciocio, and Nicole, are participating in an online problem-solving contest. They solve problems over n days with fixed rules. On day 1, each of them solved 1 problem, and on day 2, each solved 3 problems. For every day from day 3 onward, they follow these recurrences:
For nodgd:
$$a_{k+2} = p\,a_{k+1} + q\,a_k + b_{k+1} + c_{k+1} + r\,k^2 + t\,k + 1$$
For Ciocio:
$$b_{k+2} = u\,b_{k+1} + v\,b_k + a_{k+1} + c_{k+1} + w^k$$
For Nicole:
$$c_{k+2} = x\,c_{k+1} + y\,c_k + a_{k+1} + b_{k+1} + z^k + k + 2$$
Here, the indices follow that for each integer k starting from 1 (which corresponds to computing the 3rd day when k=1). The constants \(p, q, r, t, u, v, w, x, y, z\) are given positive integers.
Your task is to determine the number of problems solved by each friend on day n, and output these values modulo m.
Note: Use the initial conditions: \(a_1=b_1=c_1=1\) and \(a_2=b_2=c_2=3\).
inputFormat
The input consists of two lines:
- The first line contains two positive integers n and m, where n (\(n \ge 1\)) is the number of days and m is the modulo.
- The second line contains 10 positive integers: \(p, q, r, t, u, v, w, x, y, z\), which are the constants used in the recurrences.
outputFormat
Output three space-separated integers, representing the number of problems solved on day n by nodgd, Ciocio, and Nicole respectively, modulo m.
sample
1 100
1 1 1 1 1 1 1 1 1 1
1 1 1