Codeforces Round #257 (Div. 2 ) B. Jzzhu and Sequences
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).
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
#define M 1000000007
int main()
{
__int64 n,a[];
scanf("%I64d%I64d%I64d", &a[], &a[], &n);
a[]=a[]%M;
a[]=a[]%M;
a[]=(a[]-a[])%M;
a[]=(-a[])%M;
a[]=(-a[])%M;
a[]=(a[]-a[])%M;
printf("%I64d\n", a[(n-)%]>=? a[(n-)%] : a[(n-)%]+M); return ;
}
Codeforces Round #257 (Div. 2 ) B. Jzzhu and Sequences的更多相关文章
- 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 #433 (Div. 2)【A、B、C、D题】
题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...
- 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) B
B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #257 (Div. 2) 题解
Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes inp ...
- 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. 2) A. Jzzhu and Children(简单题)
题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...
- Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)
主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...
随机推荐
- urllib2使用初探
在入门urllib2之前,我想应该先调研一下urllib与urllib2的区别[1].首先我们要明白的是,这两个模块不可以相互替代.两者都是接受URL请求的模块,但是提供了不同的功能,两个显著的区别是 ...
- TF-池化函数 tf.nn.max_pool 的介绍
转载自此大神 http://blog.csdn.net/mao_xiao_feng/article/details/53453926 max pooling是CNN当中的最大值池化操作,其实用法和卷积 ...
- tensorflow中的boolean_mask
将mask中所有为true的抽取出来,放到一起,这里从n维降到1维度 tensor = [[1, 2], [3, 4], [5, 6]] import numpy as np mask=np.arra ...
- 洛谷P2016战略游戏
传送门啦 战略游戏这个题和保安站岗很像,这个题更简单,这个题求的是士兵人数,而保安站岗需要求最优价值. 定义状态$ f[u][0/1] $ 表示 $ u $ 这个节点不放/放士兵 根据题意,如果当前节 ...
- Effective STL 学习笔记 Item 21:Comparison Function 相关
Effective STL 学习笔记 Item 21:Comparison Function 相关 */--> div.org-src-container { font-size: 85%; f ...
- [Torch]的安装
1 安装Torch 本文介绍Torch7的安装方法,因为本人安装Torch前安装了caffe,所以可能CUDA.cudnn.Blas等Torch可能需要用来的库的安装就不再重复介绍了,相关依赖出现问题 ...
- HBase应用之微博案例
一. 需求分析 1) 微博内容的浏览,数据库表设计 2) 用户社交体现:关注用户,取关用户 3) 拉取关注的人的微博内容 二. 代码实现 代码设计总览: 1.创建命名空间以及表名的定义 //获取配置 ...
- 基于范围的for循环
语法: for ( for-range-declaration : expression ) statement 注意一般用auto表达类型.不需要修改时常用引用类型 例子: // range-bas ...
- LoadRunner测试ajax框架,回放后系统中没有产生数据解决方法
1.QTP11 下载地址:http://www.genilogix.com/downloads/unified-functional-testing/quicktest-professional-11 ...
- span 超出内容自动换行
<span style="width:80%;word-break:normal;display:block;word-warp:break-word;overflow:hidden; ...