Jzzhu and Sequences
2014-08-17 23:03
99 查看
这是一道规律题目,大家用程序写一段数据出来自己看一下就会发现里面的规律,它是以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; }
相关文章推荐
- 数学 找规律 Jzzhu and Sequences
- Jzzhu and Sequences CodeForces - 450B 矩阵快速幂
- 矩阵快速幂-- Jzzhu and Sequences CodeForces - 450B
- Jzzhu and Sequences CodeForces - 450B
- Codeforces Round #257 (Div. 2/A)/Codeforces450A_Jzzhu and Children
- (CF#257)C. Jzzhu and Chocolate
- Jzzhu and Chocolate - CF 449C 贪心
- Codeforces Round #257 C.Jzzhu and Chocolate
- Codeforces 449 B. Jzzhu and Cities
- Codeforces Round #257 (Div. 2) D题:Jzzhu and Cities 删特殊边的最短路
- Jzzhu and Children
- cf 450c Jzzhu and Chocolate
- codeforces Jzzhu and Cities
- CodeForces 449 C.Jzzhu and Apples(构造+数论)
- [高维前缀和] Codeforces 449D - Jzzhu and Numbers
- Codeforces Round #257 (Div. 2/B)/Codeforces450B_Jzzhu and Sequences
- cf #257(Div.2) A. Jzzhu and Children
- Codeforces Div. 2 #257-A. Jzzhu and Children
- Codeforces 449B_Jzzhu and Cities
- Codeforces Round #257 (Div. 2) D. Jzzhu and Cities