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 3
3
Output
1
Input
0 -1
2
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<iostream>
using namespace std;
#define modulo 1000000007
int main()
{
__int64 q[6];
int m,n;
int k;
while(~scanf("%d%d",&m,&n))
{
q[1]=m;
q[2]=n;
q[3]=n-m;
q[4]=-m;
q[5]=-n;
q[0]=m-n;
cin>>k;
k=k%6;
while(q[k]<0)
q[k]=q[k]+modulo; printf("%I64d\n",q[k]%modulo);
}
return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

Codeforces Round #257 (Div. 2) B Jzzhu and Sequences的更多相关文章

  1. Codeforces Round #257(Div. 2) B. Jzzhu and Sequences(矩阵高速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B B. Jzzhu and Sequences time limit per test 1 sec ...

  2. Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...

  3. Codeforces Round #257 (Div. 2/B)/Codeforces450B_Jzzhu and Sequences

    B解题报告 算是规律题吧,,,x y z -x -y -z 注意的是假设数是小于0,要先对负数求模再加模再求模,不能直接加mod,可能还是负数 给我的戳代码跪了,,. #include <ios ...

  4. Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)

    主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...

  5. Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)

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

  6. Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)

    题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...

  7. Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp

    D - Jzzhu and Numbers 这个容斥没想出来... 我好菜啊.. f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥. 求f[ S ] ...

  8. Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate

    C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. Codeforces Round #257 (Div. 2) A. Jzzhu and Children

    A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standar ...

随机推荐

  1. Python 文本解析器

    Python 文本解析器 一.课程介绍 本课程讲解一个使用 Python 来解析纯文本生成一个 HTML 页面的小程序. 二.相关技术 Python:一种面向对象.解释型计算机程序设计语言,用它可以做 ...

  2. ls命令显示可执行的文件 ls -F

    ls命令显示可执行的文件  ls -F

  3. 清华集训2014 day1 task1 玛里苟斯

    题目 这可算是描述很简单的一道题了!但是不简单. \(S\)是一个可重集合,\(S = \{a_1, a_2, \dots, a_n \}\). 等概率随机取\(S\)的一个子集\(A = \{a_{ ...

  4. OGR – Merging Multiple SHP files

    So I have 25 shapefiles with data for 25 counties, and I want to merge them all into one shapefile. ...

  5. 使用ffmpeg视频编码过程中踩的一个坑

           今天说说使用ffmpeg在写视频编码程序中踩的一个坑,这个坑让我花了好多时间,回头想想,非常多时候一旦思维定势真的挺难突破的.以下是不对的编码结果:                   ...

  6. 在Service中使用广播接受者

    1.清单文件 <service android:name="com.example.callmethod.MyService"></service> 2.开 ...

  7. Windows cmd

    windows常用命令 http://www.cnblogs.com/kekec/p/3662125.htmlwindows批处理语法 http://www.cnblogs.com/kekec/p/3 ...

  8. EL显示List里嵌套map(Spring MVC3)返回的model

    <c:forEach items="${requestScope.courseList}" var="cMap" varStatus="stat ...

  9. perl 回调函数

    在计算机程序设计中,回调函数,或简称回调(Callback),是指通过函数参数传递到其它代码的,某一块可执行代码的引用.这一设计允许了底层代码调用在高层定义的子程序. 没啥不好理解的呀,就是向函数的参 ...

  10. AngularJS_百度百科

    AngularJS_百度百科     AngularJS    编辑     AngularJS是为克服HTML在构建应用上的不足而设计的.    目录         1简介引引        端对 ...