Codeforces Round #257 (Div. 2) B Jzzhu and Sequences
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).
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 a single integer representing fn modulo
1000000007 (109 + 7).
2 3
3
1
0 -1
2
1000000006
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的更多相关文章
- 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 ...
- Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)
题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...
- Codeforces Round #257 (Div. 2/B)/Codeforces450B_Jzzhu and Sequences
B解题报告 算是规律题吧,,,x y z -x -y -z 注意的是假设数是小于0,要先对负数求模再加模再求模,不能直接加mod,可能还是负数 给我的戳代码跪了,,. #include <ios ...
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
- Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)
题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...
- Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)
题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...
- Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp
D - Jzzhu and Numbers 这个容斥没想出来... 我好菜啊.. f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥. 求f[ S ] ...
- 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 ...
- 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 ...
随机推荐
- C# 课堂总结5-数组
一. 数组:解决同一类大量数据在内存存储和运算的功能. 1.一维数组定义:制定类型,指定长度,指定名称.int[] a=new int[5]int[] a=new int[5]{23,23,23,1, ...
- java --对象流与对象的序列化
对象流 ObjectInputStream ObjectOutputStream类分别是InputStream和OutputStream的子类,对象输出流使用writeObject(Object ob ...
- Qt新建线程的方法(有QRunnable,QThreadPool,moveToThread和QtConcurrent的例子)
看了不少Qt线程的东西,下面总结一下Qt新建一个线程的方法. 一.继承QThread 继承QThread,这应该是最常用的方法了.我们可以通过重写虚函数void QThread::run ()实现我们 ...
- Android_简单笔记一
入门学习Android的简单笔记(已经安装好了开发环境ADT) 一.关于 AndroidManifest.xml文件 1. android:icon和android:label定义了应用程序安装后显示 ...
- 简单的http代理服务器
简单的http代理服务器 本项目课程是基于 Python 实现的一个简单的 HTTP 代理服务器,要求用户需了解 Python 基础和一定的 HTTP 服务器基础知识.
- poj 3258 River Hopscotch 【二分】
题目真是不好读,大意例如以下(知道题意就非常好解了) 大致题意: 一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L. 河中有n块石头,每块石头到S都有唯一的距 ...
- hdu1334-Perfect Cubes
http://acm.hdu.edu.cn/showproblem.php?pid=1334 题意;求200以内所有满足a^ 3 == b^ 3 + c ^ 3 +d ^ 3 #include< ...
- js注册检测 用户名、密码、手机号、邮箱
请输入电话号码:<input name="" type="text" id="telphone" value="" ...
- Mybatis 示例之 复杂(complex)属性(property)
Mybatis示例专栏:http://blog.csdn.net/column/details/mybatis-sample.html Mybatis的复杂属性,Mybatis的这个特点很少被提及,但 ...
- IT段子,娱乐一下
1.我是个程序员,一天我坐在路边一边喝水一边苦苦检查bug.这时一个乞丐在我边上坐下了,开始要饭,我觉得可怜,就给了他1块钱,然后接着调试程序.他可能生意不好,就无聊的看看我在干什么,然后过了一会,他 ...