B. Jzzhu and Sequences
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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).

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).

----------------------------------------------------------------------------

题意就不说了,找最小循环节点,就是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的更多相关文章

  1. 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 ...

  2. Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)

    题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...

  3. Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...

  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. 2) B. Jzzhu and Sequences(矩阵高速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B B. Jzzhu and Sequences time limit per test 1 sec ...

  7. Codeforces Round #257 (Div. 2)

    A - Jzzhu and Children 找到最大的ceil(ai/m)即可 #include <iostream> #include <cmath> using name ...

  8. Codeforces Round #257(Div.2) D Jzzhu and Cities --SPFA

    题意:n个城市,中间有m条道路(双向),再给出k条铁路,铁路直接从点1到点v,现在要拆掉一些铁路,在保证不影响每个点的最短距离(距离1)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路 ...

  9. Codeforces Round #257 (Div. 2) A题

    A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standar ...

随机推荐

  1. linux下网卡启动、配置

    步骤1.配置/etc/sysconfig/network-scripts/ifcfg-eth0 里的文件. ifcfg-eth0的配置详情:[root@localhost ~]# vim /etc/s ...

  2. EL表达式简介

    EL表达式简介 EL 全名为Expression Language.EL主要作用: 1.获取数据 EL表达式主要用于替换JSP页面中的脚本表达式,以从各种类型的web域 中检索java对象.获取数据. ...

  3. linux设备驱动归纳总结(八):1.总线、设备和驱动【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-109733.html linux设备驱动归纳总结(八):1.总线.设备和驱动 xxxxxxxxxxxx ...

  4. Android NDK 开发(一)--环境搭建【转】

    转载请注明出处:http://blog.csdn.net/allen315410/article/details/41800955 Android下的NDK开发是Android开发中不可或缺的一部分, ...

  5. js获取IP地址方法总结_转

    js代码获取IP地址的方法,如何在js中取得客户端的IP地址.原文地址:js获取IP地址的三种方法 http://www.jbxue.com/article/11338.html 1,js取得IP地址 ...

  6. jQuery_Ajax_Json 异步接收PHP端传来的json数据

    [json]{"user_id":"1172940","rmb_point":"0","weixin_id&q ...

  7. git 冲突

    git中冲突会用特殊的标记 (<<<<<<<=======>>>>>>>) 特殊标记<<<< ...

  8. java final .static修饰符

    static静态修饰符(使用static修饰符修饰的成员变量.常量.和成员方法成为静态变量.常量和方法,他们统称为静态成员,归整个类所有,不依赖于类的特定实例,被类的所有实例共享,只要这个类被加载,J ...

  9. html里文本保留换行格式

    用<pre></pre>把文本包起来

  10. Django的第一个web程序及深入学习

    本学习历程参照Practical Django Projects和http://djangobook.py3k.cn上翻译的内容进行 注:本例以本机加以说明: 根据Django的安装过程可知:在命令行 ...