No.1105 Many Triplets
Problem Statement
Consider integer sequences $A,B,C$ with $N$ elements each.
Suppose the values of these sequences satisfy the following conditions for $2 \leq i \leq N$.
・ $A_i = A_{i-1}-B_{i-1}$
・ $B_i=B_{i-1}-C_{i-1}$
・ $C_i=C_{i-1}-A_{i-1}$
Given $(A_1,B_1,C_1)$, find each of $(A_N,B_N,C_N)$ modulo $10^9+7$.
In this problem, the remainder of an integer $X$ divided by $10^9+7$ refers to the unique integer $r$ such that $X = q \times (10^9+7) + r$ for some integer $q$ and $0 \leq r < 10^9+7$.
Input
$N$ $A_1\ B_1\ C_1$
All inputs are integers.
$2 \leq N \leq 10^{18}$
$0 \leq A_1,B_1,C_1 \leq 10^9$
Output
Output each of $(A_N,B_N,C_N)$ modulo $10^9+7$, separated by spaces. Print a newline at the end.
Sample
Sample 1
Input
2 1 2 3
Output
1000000006 1000000006 2
The remainder of $-1$ divided by $10^9+7$ is $10^9+6$.
Sample 2
Input
3 0 0 0
Output
0 0 0
Sample 3
Input
10 1000000000 998244353 924844033
Output
945425885 912366722 142207407
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
TAISA_
shibh308