問題一覧 > 通常問題

No.3228 Very Large Fibonacci Sum

レベル : / AI推定難易度 : 1525 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 69
作問者 : ジュ・ビオレ・グレイス / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 12489 / 自分の提出
問題文最終更新日: 2025-07-31 21:37:46
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 477 線形代数コンテスト (順位表) の他の問題:

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