Codeforces Round #257 (Div. 2) B
1 second
256 megabytes
standard input
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).
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).
----------------------------------------------------------------------------
题意就不说了,找最小循环节点,就是6
然后注意数组要从0开始,并且负数取余要让它加上一个整数(1000000007)然后再取余,就没什么了
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h> int main()
{
long long n,m,i,j,k,t;
long long str[];
while(scanf("%I64d%I64d",&n,&m)!=EOF)
{
scanf("%I64d",&t);
str[]=(n+)%;
str[]=(m+)%;
for(i=;i<;i++)
{
str[i]=(str[i-]-str[i-]);//printf("%I64d*",t%6);
}
printf("%I64d\n",(str[(t-)%]+)%);
//else
//printf("%I64d\n",str[t%6]%1000000007);
}
return ;
}
Codeforces Round #257 (Div. 2) B的更多相关文章
- Codeforces Round #257 (Div. 1)A~C(DIV.2-C~E)题解
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and ...
- Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)
题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...
- 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. 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. 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)
A - Jzzhu and Children 找到最大的ceil(ai/m)即可 #include <iostream> #include <cmath> using name ...
- Codeforces Round #257(Div.2) D Jzzhu and Cities --SPFA
题意:n个城市,中间有m条道路(双向),再给出k条铁路,铁路直接从点1到点v,现在要拆掉一些铁路,在保证不影响每个点的最短距离(距离1)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路 ...
- Codeforces Round #257 (Div. 2) A题
A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standar ...
随机推荐
- 鸟哥的linux私房菜学习记录之查看帮助文档
如何使用man查看帮助文件 man command例如man date 按下enter键之后会显示date帮助文件,指令后面会有一个代号 info的用法 关机的几个常用命令 shutdown,halt ...
- eclipse Juno Indigo Helios Galileo这几种版本的意思
Eclipse 3.1 版本代号 IO [木卫1,伊奥] Eclipse 3.2, 30-06-2006, Callisto projects, 版本代号 Callisto [木卫四,卡里斯托 ] ...
- 那些情况该使用它们spin_lock到spin_lock_irqsave【转】
转自:http://blog.csdn.net/wesleyluo/article/details/8807919 权声明:本文为博主原创文章,未经博主允许不得转载. Spinlock的目的是用来同步 ...
- 【原创】纯干货,Spring-data-jpa详解,全方位介绍。
本篇进行Spring-data-jpa的介绍,几乎涵盖该框架的所有方面,在日常的开发当中,基本上能满足所有需求.这里不讲解JPA和Spring-data-jpa单独使用,所有的内容都是在和Spring ...
- MD5加密,Base64加密/解密,AES加密/解密
1.从github上下载GTMBase64-master和AESCrypt-ObjC-master导入工程,如下图所示. 2.使用前的配置及注意事项: (1) 在build phases中的GTMBa ...
- Quartz2D简介及基本线条绘制
* Quartz2D简介 1.什么是Quartz2D? 他是一个二维的绘图引擎,同时支持iOS和Mac系统 2.Quartz2D能完成的工作 画基本线条,绘制文字,图片,截图,自定义UIView. 3 ...
- Python 编码规范
官网规范:https://www.python.org/dev/peps/pep-0008/ 1.不在同一句import中引用多个库 # 正确姿势: import os import sys # 错误 ...
- snackbar初体验
底部弹出的部分就是snackbar的,右侧可添加一个action响应点击事件,遗憾的时貌似只能添加一个 这是华为mate8上面运行出来的效果,颜色之类的都是默认.不同的android版本样式稍有差异 ...
- Android 5.1 - 状态栏充电标志问题
Android 5.1 Ubuntu14.04 SourceInsigh 电量已满,插着USB头,观察Settings - Battery,电量为100%,状态为full,但仍有充电图标rust 之 ...
- Android 内存优化 (防Memory Leak)
在之前的 Android 内存管理 &Memory Leak & OOM 分析 中,说到了Android的内存管理相关的原理,也能了解到Android Memory Leak 和 ...