Jzzhu and Sequences(找规律)
2020-07-16 06:07
1051 查看
Jzzhu has invented a kind of sequences, they meet the following property:
You are given x and y, please calculate f n modulo 1000000007 (109 + 7).
Input
The first line contains two integers x and y (|x|, |y| ≤ 109). The second line contains a single integer n (1 ≤ n ≤ 2·109).
Output
Output a single integer representing f n modulo 1000000007 (109 + 7).
Examples
Input
2 3
3
Output
1
Input
0 -1
2
Output
1000000006
找规律的题目!
很神奇!
#include <iostream> using namespace std; const int MOD = 1000000007; const int N = 6; int ans[N]; int main() { int x, y, n; cin >> x >> y >> n; // Init ans ans[0] = x - y; ans[1] = x; ans[2] = y; ans[3] = y - x; ans[4] = -x; ans[5] = - y; int result = ans[n % N]; if(result >= 0) cout << result % MOD << endl; else cout << (result % MOD + MOD) % MOD << endl; return 0; }
相关文章推荐
- 数学 找规律 Jzzhu and Sequences
- Jzzhu and Sequences
- 450A - Jzzhu and Children 找规律也能够模拟
- Jzzhu and Sequences CodeForces - 450B 矩阵快速幂
- 450A - Jzzhu and Children 找规律也可以模拟
- Jzzhu and Sequences CodeForces - 450B
- 矩阵快速幂-- Jzzhu and Sequences CodeForces - 450B
- HDU1267 下沙的沙子有几粒?【找规律】
- HDU5086:Revenge of Segment Tree(规律题)
- HDU5100(找规律)
- CSDN博客的积分计算方法和博客排名规律
- HLJUOJ1012(找规律)
- 02_IO操作的基本规律(InputStream,OutputStream,Reader,Writer,FileReader,FileWriter,BufferedReader,BufferedWri
- Java 按规律将字符串分割为do…
- 信息产业规律之70-20-10律
- The ? 1 ? 2 ? ... ? n = k problem ——求和规律
- 数学+找规律题
- HDU--2502月之数【水题】【规律】
- hdu 1021 (找规律题)
- struts2 namespace 规律