Jzzhu and Sequences
来源:互联网 发布:nginx反向代理 缓存 编辑:程序博客网 时间:2024/06/05 02:51
这是一道规律题目,大家用程序写一段数据出来自己看一下就会发现里面的规律,它是以6为基础进行循环的,还有一点就是他的取余和程序运行的不一致,所以我们需要稍微处理一下,最后一点就是数据很大,数组的话会超出范围,也会超出题目限制的范围,所以这里使用滚动数组的方法,具体的前面已经讲过,大家也可以看看相关的资料:
#include<iostream>using namespace std;int main(){ int x,y,i,j,k; int a[10]; while(cin>>x>>y) { //cout<<(-1%1000000007)<<endl; cin>>k; a[0]=x; a[1]=y; a[0]=(a[0]+1000000007)%1000000007; a[1]=(a[1]+1000000007)%1000000007; for(i=2;i<6;i++) { a[i]=a[i-1]-a[i-2]; a[i]=(a[i]+1000000007)%1000000007; } a[(k-1)%6]=(a[(k-1)%6]+1000000007)%1000000007; cout<<a[(k-1)%6]<<endl; } return 0;}
0 0
- B. Jzzhu and Sequences
- Jzzhu and Sequences
- B. Jzzhu and Sequences
- cf450B. Jzzhu and Sequences
- Jzzhu and Sequences CodeForces
- Jzzhu and Sequences
- Jzzhu and Sequences CodeForces
- Jzzhu and Sequences CodeForces
- Jzzhu and Sequences CodeForces
- codeforces B. Jzzhu and Sequences
- codeforces-DIV2-B- Jzzhu and Sequences
- Codeforces 450 B. Jzzhu and Sequences
- (CF#257)B. Jzzhu and Sequences
- Codeforces Jzzhu and Sequences(循环节)
- Codeforces 450B Jzzhu and Sequences
- CF 450B Jzzhu and Sequences
- CodeForces 450-B. Jzzhu and Sequences
- Codeforces #257 div2 B. Jzzhu and Sequences
- 【专题】—【DP】—【最长增长子序列】
- FFmpeg研究之路
- Android学习笔记_02 – Service的测试应用
- 杭电2012
- 【剑指offer合集】
- Jzzhu and Sequences
- 函数心得
- 日期类-求星期几
- ASCII码对照表
- eclipse启动tomcat访问不到主页
- 虚拟ONVIF 摄像机
- maven assembly plugin使用
- Python的内置类型续
- 用户体验之保存用户登录信息