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 ...
随机推荐
- tweenanim动画
1.视图 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...
- GCD基本使用
主要概念 队列 dispatch_queue_t,队列名称在调试时辅助,无论什么队列和任务,线程的创建和回收不需要程序员操作,有队列负责. 串行队列:队列中的任务只会顺序执行(类似跑步) dispat ...
- 【转】文件恢复神器extundelete
参考博文: 1.Linux中VMware虚拟机增加磁盘空间的扩容操作 http://www.net130.com/CMS/Pub/special/special_virtual/special_vir ...
- git gitk命令
通过gitk命令,在单独的界面上查看项目源码在各个时间点上的代码提交情况. 各个commit 各个tag ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` 更多详细的介绍 ...
- 获取浏览器版本Asp.Net
public static string GetBrowser() { HttpBrowserCapabilities bc = HttpContext.Current.Request.Browser ...
- GTest交流与经验总结
GTest交流与经验总结 原文见: http://starsourcingsolutions.com/myblog/?p=159
- linux下编译.so 和.a 可能出现的问题 ?
1. 静态函数库 这类库的名字一般是libxxx.a:利用静态函数库编译成的文件比较大,因为整个 函数库的所有数据都会被整合进目标代码中,他的优点就显而易见了,即编译后的执行程序不需要外部的函数库支持 ...
- 使Web Api 支持跨域资源共享(CORS)
Reference:http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api Imp ...
- Juuluu 旗下企业站点管理系统3.0.1公布!
KgE金刚企业站点管理系统是广州聚龙软件为国内中小企业开发的一款企业站点管理系统,KgE採用可视化的标签模型,可在Dreamvear等网页编辑下可视化编辑,KgE使用javaeemsyqlyuijqu ...
- 基于W5500+Yeelink的远程灯光控制设计
概述 工具:物联网云平台Yeelink DHT11温湿度传感器 W5500EVB 编译环境:Keil4 目的:通过以太网实时监控远程某个位置的温度和湿度 在W5500EVB端连接LED灯.通过W ...