CF450B.Jzzhu and Sequences

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Jzzhu has invented a kind of sequences, they meet the following property:

You are given xx and yy , please calculate fnf_{n} modulo 10000000071000000007 (109+7)(10^{9}+7) .

输入格式

The first line contains two integers xx and yy (x,y<=109)(|x|,|y|<=10^{9}) . The second line contains a single integer nn (1<=n<=2109)(1<=n<=2·10^{9}) .

输出格式

Output a single integer representing fnf_{n} modulo 10000000071000000007 (109+7)(10^{9}+7) .

输入输出样例

  • 输入#1

    2 3
    3
    

    输出#1

    1
    
  • 输入#2

    0 -1
    2
    

    输出#2

    1000000006
    

说明/提示

In the first sample, f2=f1+f3f_{2}=f_{1}+f_{3} , 3=2+f33=2+f_{3} , f3=1f_{3}=1 .

In the second sample, f2=1f_{2}=-1 ; 1-1 modulo (109+7)(10^{9}+7) equals (109+6)(10^{9}+6) .

首页