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     }

 

 

posted @ 2019-07-24 15:25  dodoBehind  阅读(153)  评论(0编辑  收藏  举报