| TheForces Round #40 (Maths-Forces) |
|---|
| Закончено |
The Fibonacci sequence, where each number is the sum of the two preceding ones, is well-known in mathematics. Consider a sequence $$$a$$$ that follows a similar pattern but with subtraction instead of addition.
Given three integers $$$n$$$, $$$a_1$$$, and $$$a_2$$$. For $$$i \geq 3$$$, $$$a_i = a_{i-1} - a_{i-2}$$$.
Your task is to find
$$$$$$\sum_{i = 1}^{n} a_i \mod (10^9 + 7)$$$$$$
The input begins with a single integer $$$t$$$ $$$(1 \leq t \leq 10^5)$$$, the number of test cases.
Each of the next $$$t$$$ lines contains three integers $$$n$$$, $$$a_1$$$, and $$$a_2$$$ $$$(1 \leq n, a_1, a_2 \leq 10^9)$$$.
For each test case, output the answer.
63 2 54 1 21 1 13 10 3799843967 796619138 4461736071000000000 1000000000 1000000000
10 3 1 6 649554476 1000000000
| Название |
|---|


