No.3228 Very Large Fibonacci Sum
タグ : / 解いたユーザー数 69
作問者 :
ジュ・ビオレ・グレイス
/ テスター :
👑 Problem Statement
Define the generalized Fibonacci numbers $F_n$ by $F_0 = a, \, F_1 = b, \, F_n = cF_{n-1} + dF_{n-2} + e \ (n \geq 2)$.
Find the remainder when $F_0 + F_1 + \cdots + F_N$ is divided by $1000000007$. Here, the remainder is always at least $0$ and less than $1000000007$.
Input
$a\ b\ c\ d\ e\ N$
$-10^8 \leq a, b, c, d, e \leq 10^8, \ 0 \leq N \leq 10^{18}$ are all integers.
Output
Output the remainder when $F_0 + F_1 + \cdots + F_N$ is divided by $1000000007$. Print a newline at the end.
Sample
Sample 1
Input
1 1 1 1 0 2
Output
4
This is the sum of the ordinary Fibonacci sequence. $F_0 = 1, F_1 = 1, F_2 = 2.$
Sample 2
Input
1 2 3 4 5 6
Output
5092
Sample 3
Input
2 3 -8 -9 5 0
Output
2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。