問題一覧 > 通常問題

No.891 隣接3項間の漸化式

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 203
作問者 : trineutron / テスター : QCFium
お気に入りにしたユーザー ProblemId : 3068 / 自分の提出
問題文最終更新日: 2022-04-26 01:56:32
Three-Term Recurrence Relation
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. Show the original
yukicoder contest 224 (順位表) の他の問題:

Problem Statement

Let $a, b, n$ be integers at least $0$ and less than $10^9+7$. Given $x_0=0, x_1=1, x_{i+2}=ax_{i+1}+bx_i (i \ge 0)$, find the remainder when $x_n$ is divided by $10^9+7$.

Input

$a\ b\ n$

All inputs are integers.
$0 \le a, b, n \lt 10^9+7$

Output

Output the remainder when $x_n$ is divided by $10^9+7$, followed by a newline.

Sample

Sample 1
Input
1 1 10
Output
55

Sample 2
Input
10 10 10
Output
30499986

Sample 3
Input
1000000000 0 100
Output
7642709

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。