codeforces 257div2 B. Jzzhu and Sequences(细节决定一切)
题目链接:http://codeforces.com/contest/450/problem/B
解题报告:f1 = x,f2 = y,另外有当(i >= 2) fi = fi+1 + fi-1,现在给出x和y,k,让你输出fn % (1e9+7)
对于这题我真想说细节决定一切,f的值一共只有6个,只要把f的值全部打表打出来了就可以直接得出任何一个fk的值。
但是注意x和y的范围都是小于10^9,所以当(x+y) % MOD的时候就会可能出现还是负数的情况,所以说交题之前最好测下极端的情况,因为错误往往是在这些地方犯的。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long INT;
INT ans[];
const INT MOD = ;
void dabiao(INT x,INT y)
{
x = (x + MOD) % MOD; //先单个分别对x,y处理就不会出现取模之后还是负数的情况
y = (y + MOD) % MOD;
ans[] = x;
ans[] = y;
ans[] = (y - x + MOD) % MOD;
ans[] = (- * x + MOD) % MOD;
ans[] = (- * y + MOD) % MOD;
ans[] = (x - y + MOD) % MOD;
}
int main()
{
INT x,y,n;
while(scanf("%lld%lld%lld",&x,&y,&n)!=EOF)
{
dabiao(x,y);
printf("%lld\n",ans[(n - ) % ]);
}
return ;
}
codeforces 257div2 B. Jzzhu and Sequences(细节决定一切)的更多相关文章
- codeforces 450B B. Jzzhu and Sequences(矩阵快速幂)
题目链接: B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input ...
- codeforces 450 B Jzzhu and Sequences
题意:给出f1=x,f2=y,f(i)=f(i-1)+f(i+1),求f(n)模上10e9+7 因为 可以求出通项公式:f(i)=f(i-1)-f(i-2) 然后 f1=x; f2=y; f3=y-x ...
- CodeForces 450B Jzzhu and Sequences (矩阵优化)
CodeForces 450B Jzzhu and Sequences (矩阵优化) Description Jzzhu has invented a kind of sequences, they ...
- 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 ) B. Jzzhu and Sequences
B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...
- CodeForces - 450B Jzzhu and Sequences —— 斐波那契数、矩阵快速幂
题目链接:https://vjudge.net/problem/CodeForces-450B B. Jzzhu and Sequences time limit per test 1 second ...
- Codeforces450 B. Jzzhu and Sequences
B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...
- CF450B Jzzhu and Sequences(矩阵加速)
CF450B Jzzhu and Sequences 大佬留言:这.这.不就是矩乘的模板吗,切掉它!! You are given xx and yy , please calculate $f_{n ...
- 数学 找规律 Jzzhu and Sequences
A - Jzzhu and Sequences Jzzhu has invented a kind of sequences, they meet the following property: ...
随机推荐
- 一个优秀的Android应用从建项目开始
1.项目结构 现在的MVP模式越来越流行.就默认采用了.如果项目比较小的话: app——Application Activity Fragment Presenter等的顶级父类 config——AP ...
- Android学习第六弹之Touch事件的处理
在移动开发过程当中,我们经常会遇到手势处理和事件触摸的情况,如果不了解整个事件的处理机制,对于开发的同学和码农是非常痛苦的,但是事件触摸的处理确实是一个非常复杂的过程,细讲起来,估计我都能讲迷糊,这里 ...
- 关于 hangfire 初始化工作机制
hangfire初始化的配置方法 :UseHangfire . public static class OwinBootstrapper { /// <summary> /// Boots ...
- 每天一个linux命令(11):less 命令
less 工 具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性. 在 more 的时候,我们并没有办法向前 ...
- 大概了解了flexbox
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 【Matplotlib】 标注一些点
相关的文档: Annotating axis annotate() command 标注的代码如下: ... t = 2 * np.pi / 3 plt.plot([t, t], [0, np.cos ...
- 第七节 JBPM 中的脚本语言
1.JPDL表达式 2.动作:数据库操作例子 3.路由:transaction一个流程之间的指向 4.BeanShell脚本语言 例子: 发布到数据库中才能做一个测试类
- BZOJ-1202 狡猾的商人 并查集+前缀和
我记得这个题,上次之前做的时候没改完,撂下了,今天突然想改发现,woc肿么A 了= =看来是我记错了.. 1202: [HNOI2005]狡猾的商人 Time Limit: 10 Sec Memory ...
- [HNOI2010]BOUNCE 弹飞绵羊
题目描述 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏.游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系 ...
- CustomerConfigHelper
public static class CustomerConfigHelper { public static object _lockObject = new object(); private ...