您好,欢迎访问一九零五行业门户网

Codeforces Round #258 (Div. 2) B. Jzzhu and Sequences(矩阵快速幂)_html/css_WEB-ITnose

题目链接:http://codeforces.com/problemset/problem/450/b
----------------------------------------------------------------------------------------------------------------------------------------------------------

欢迎光临天资小屋: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
其它类似信息

推荐信息