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. 搭建OA平台

    公司没有OA平台的原因是: 1.暂时没有上的必要. 2.总厂有一个web版的用友的OA. 但最近法方总经理提到了共享日历日程的需求. 这个需求的主要要整合的是把outlook的日历功能共享.原来微软是 ...

  2. 网页制作之html基础学习1-简介

    学习网页制作主要分为三大块 1.HTML    超文本标记语言( 全称:Hyper Text  Markup Language) 专门编辑静态网页 2.CSS      网页美化:是HTML控制的样式 ...

  3. 介绍 32 位和 64 位版本的 Microsoft Office 2010

    在使用 64 位版本的 Office 2010 运行现有解决方案时存在两个基本问题: Office 2010 中的本机 64 位进程无法加载 32 位二进制文件.在使用现有 Microsoft Act ...

  4. 用定时器T0查询方式P0口8位控制LED闪烁

    #include<reg52.h> #define uchar unsigned char #define uint unsigned int void main (void) { uch ...

  5. android电话接通状态下,关机铃声无法从外放输出

    AudioMTKPolicyManager.cpp的startOutput方法中.将在newDevic获取到的后面加入: if(stream==AudioSystem::BOOT)newDevice| ...

  6. 项目优化经验分享(六)SVN冲突和处理

    上一篇博客我们分享了新增需求的确定思想<站在全局看问题>.今天我们来分享项目开发中SVN冲突的解决经验:SVN冲突和处理! 引言 开发过项目的人都知道,公司开发一个项目都会使用到版本号控制 ...

  7. 搭建Windows SVN服务器及TortoiseSVN使用帮助和下载

    搭建Windows SVN服务器: 用的SVN服务器通常为外部,例如Google Code的服务器,不过,做为一个程序开发人员,就算自己一个人写程序,也应该有一个SVN版本控制系统,以便对开发代码进行 ...

  8. POJ 1258-Agri-Net (Kruskal)

    题目链接:Agri-Net 最小生成树水题,数组开的和题目描写叙述一样,可是就是RE,有填了个0,还好这个题用 库鲁斯卡尔 敲了一遍,发现了点问题,曾经写的库鲁卡尔模板有点问题,多写了步没用的操作,已 ...

  9. java运行脚本语言demo

    public class Test { /** * @param args * @throws IOException  */ public static void main(String[] arg ...

  10. ViewState的用法

    学习标签: ViewState 本文导读:在web窗体控件设置为runat = "server",这个控件会被附加一个隐藏的属性_ViewState,_ViewState存放了所有 ...