codeforces 450B Jzzhu and Sequences

来源:互联网 发布:网络数字用语例如2333 编辑:程序博客网 时间:2024/05/29 18:27

题目链接:http://codeforces.com/contest/450/problem/B
解题思路:找循环节,注意当f[i]是负数的时候一定要把他加上mod直到>0为止;
e:- 3 % 4 == 1;

#include <iostream>using namespace std;const int mod=1e9+7;typedef long long LL;LL f[10];int main(){    LL x,y,k;    while(cin>>x>>y>>k)    {        x = (x + mod) % mod;        y = (y + mod) % mod;        f[0] = x;        f[1] = y;        f[2] = (y - x + mod) % mod;        f[3] = (-x + mod) % mod;        f[4] = (-y + mod) % mod;        f[5] = (x - y +mod) % mod;        cout<<f[(k-1) % 6]<<endl;    }    return 0;}
0 0
原创粉丝点击