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

 #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的更多相关文章

  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 #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

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

  4. Codeforces Round #257 (Div. 2)

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

  5. Codeforces Round #257 (Div. 2) B

    B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. Codeforces Round #257 (Div. 2) 题解

    Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes inp ...

  7. Codeforces Round #257 (Div. 2/B)/Codeforces450B_Jzzhu and Sequences

    B解题报告 算是规律题吧,,,x y z -x -y -z 注意的是假设数是小于0,要先对负数求模再加模再求模,不能直接加mod,可能还是负数 给我的戳代码跪了,,. #include <ios ...

  8. Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)

    题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...

  9. Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)

    主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...

随机推荐

  1. Integer to Roman & Roman to Integer

    Integer to Roman Given an integer, convert it to a roman numeral. The number is guaranteed to be wit ...

  2. 读书笔记 effective c++ Item 52 如果你实现了placement new,你也要实现placement delete

    1. 调用普通版本的operator new抛出异常会发生什么? Placement new和placement delete不是C++动物园中最常遇到的猛兽,所以你不用担心你对它们不熟悉.当你像下面 ...

  3. Ubuntu_搜狗输入法安装

    前言 由于很少使用Linux系统,所以闲下来打算看一看,在安装完成后,遇到无法输入中文的问题.我使用的是小鹤双拼,所以习惯使用搜狗输入法,本文记录一下如何在ubuntu系统下安装小鹤双拼 由于前两次并 ...

  4. .NET 4.5 Task异步编程学习资料

    参考资料: 1. http://www.cnblogs.com/heyuquan/archive/2013/04/18/3028044.html

  5. 缓存数据库-redis数据类型和操作(sorted set)

    一:Redis 有序集合(sorted set) Redis 有序集合和集合一样也是string类型元素的集合,且不允许重复的成员. 不同的是每个元素都会关联一个double类型的分数.redis正是 ...

  6. Extjs 基础篇—— Function基础

    这里主要是JS的基础知识,也是深入理解Ext的基础.1.参数可变长,注意跟Java还是有一点区别的.例: 1.function getUser(name,age){ 2.alert("nam ...

  7. java基础22 日期类、日历类、日期格式类

    package com.dhb.code; import java.text.ParseException; import java.text.SimpleDateFormat; import jav ...

  8. Qt通过ODBC来操作Excel

    示例代码: #include<QtCore/QCoreApplication> #include<QtSql> #include<QObject> #include ...

  9. jquery 分页 下拉框

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. 如何通过Spring读取Properties文件

    1 在Spring中配置文件中, 配置配置文件的引用     <util:properties id="settings" location="/WEB-INF/c ...