坑爹的数学水题啊
不跪的话我的rating肯定会暴涨的!!!
高中做过不知道多少遍的题目!!!
首先退出an=an-1-an-2
列出a1,a2,a3...关系,可以证明出6个一循环
这道题难点不在于这里,在于取模和取余的其别!!!
求模运算和求余运算在第一步不同: 取余运算在取c的值时,向0 方向舍入(fix()函数);而取模运算在计算c的值时,向无穷小方向舍入(floor()函数)。
代码如下:
#include <cstdio>
#include <iostream>
#include <algorithm>
#define MAXN 10010
#define E 1000000007
#define LL long long
using namespace std;
int a[MAXN];
int main(void) {
int a1, a2, ans, n;
while(cin >> a1 >> a2) {
cin >> n;
switch(n%6) {
case 0:ans = a1-a2;break;
case 1:ans = a1;break;
case 2:ans = a2;break;
case 3:ans = a2-a1;break;
case 4:ans = -a1;break;
case 5:ans = a1-a2;break;
}
cout << ((ans%E)+E)%E << endl;
}
return 0;
}