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 ...
随机推荐
- filesort是什么意思?
我们碰到有order by 或者group by,或者distinct语句的时候,如果查看执行计划,通常会看到using filesort的字眼,那么这个filesort是不是真是文件排序呢?其实不然 ...
- 【python cookbook】【数据结构与算法】17.从字典中提取子集
问题:想创建一个字典,其本身是另一个字典的子集 解决方案:利用字典推导式(dictionary comprehension)可轻松解决 # example of extracting a subset ...
- windows prompt personalize 设置cmd提示的相关
由于有一篇随笔种我说要引用这篇文章,所以不得已也出来了,就像你说大话『我明天去吃屎』,结果你做到了. 我这记录一下有关windows prompt这是的变量,我不知道这算不算变量,因为windows变 ...
- iptables的四表五链
iptables只是Linux防火墙的管理工具而已,位于/sbin/iptables.真正实现防火墙功能的是netfilter,它是Linux内核中实现包过滤的内部结构. iptables包含4个表, ...
- Android 常用工具类之 DimenUtil
public class DimenUtil { /** sp转换成px */ public static int sp2px(float spValue) { float fontScale = M ...
- 【Pro ASP.NET MVC 3 Framework】.学习笔记.11.ASP.NET MVC3的细节:概览MVC项目
书Adam The Definitive Guide to HTML5 Adam Applied ASP.NET 4 in Context and Pro ASP.NET 4 到此为止,我们已经学了为 ...
- 嵌入式jetty的HTTP实现
2 嵌入式jetty的HTTP实现 布拉君君 2.1 简单HTTP实现 2.1.1 HTTP SERVER端实现 2.1.1.1 HTTP SERVER端实现概述 在代码中嵌入一个Jetty s ...
- 收藏本网站兼容火狐IE
<script type="text/javascript"> function AddFavorite(sURL, sTitle) {try { window.ext ...
- [充电][ios]ios充电接口
知乎推荐:http://www.zhihu.com/topic/19693633/top-answers 外文教学网站: http://www.raywenderlich.com/ 著作权归作者所有. ...
- EF 用CallContext上下文管理
public class ObjectContextFactory { private static CIK_NewsEntities context; public static DbContext ...