問題一覧 > 通常問題

No.1105 Many Triplets

レベル : / AI推定難易度 : 1125 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 188
作問者 : TAISA_ / テスター : shibh308
お気に入りにしたユーザー ProblemId : 4444 / 自分の提出
問題文最終更新日: 2020-06-03 00:21:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 255 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。