B. Jzzhu and Sequences

http://codeforces.com/contest/450/problem/B

 

这个数列是循环数列

1     public static void main(String[] args) {
2         IO io = new IO();
3         long a = io.nextInt(), b = io.nextInt(), n = io.nextInt();
4         long[] ans = new long[]{a, b, b - a, -a, -b, a - b};
5         long res = ans[(int) ((n - 1) % 6)];
6         while (res<0)res+=M;
7         io.println(res%M);
8     }

 

原文地址:https://www.cnblogs.com/towerbird/p/11238256.html