测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A9482. Jzzhu and Sequences

编程题 普及/提高-

题目描述

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

![](/uploads/acgo/image/c4bcdd62f23df016_fe89358ea6f4.jpeg)You are given $x$ and $y$ , please calculate $f_{n}$ modulo $1000000007$ $(10^{9}+7)$ .

输入格式

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

输出格式

Output a single integer representing $f_{n}$ modulo $1000000007$ $(10^{9}+7)$ .

输入输出样例

输入 #1
2 3
3
输出 #1
1
输入 #2
0 -1
2
输出 #2
1000000006

说明/提示

In the first sample, $f_{2}=f_{1}+f_{3}$ , $3=2+f_{3}$ , $f_{3}=1$ .

In the second sample, $f_{2}=-1$ ; $-1$ modulo $(10^{9}+7)$ equals $(10^{9}+6)$ .
上一题 去做题 下一题