----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋:http://user.qzone.qq.com/593830943/main
----------------------------------------------------------------------------------------------------------------------------------------------------------
b. jzzhu and sequences
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
jzzhu has invented a kind of sequences, they meet the following property:
you are given x and y, please calculate fn modulo 1000000007 (109?+?7).
input
the first line contains two integers x and y (|x|,?|y|?≤?109). the second line contains a single integer n (1?≤?n?≤?2·109).
output
output a single integer representing fn modulo 1000000007 (109?+?7).
sample test(s)
input
2 33
output
input
0 -12
output
1000000006
note
in the first sample, f2?=?f1?+?f3, 3?=?2?+?f3, f3?=?1.
in the second sample, f2?=-?1; ?-?1 modulo (109?+?7) equals (109?+?6).
代码如下:
#include #include #include using namespace std;struct a{ int mat[2][2];};a d,f;__int64 n,mod;a mul(a a,a b){ a t; memset(t.mat,0,sizeof(t.mat)); for(int i=0;i