Number Sequence
--------------------------------------------------------------------------------
Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 3359 Accepted Submit: 719
--------------------------------------------------------------------------------
A number sequence is defined as follows:
f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.
Given A, B, and n, you are to calculate the value of f(n).
Input
The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1 <= n <= 100,000,000). Three zeros signal the end of input and this test case is not to be processed.
Output
For each test case, print the value of f(n) on a single line.
/*翻译如下,大家对照一下,不一定翻译的正确.*/
定义一个数序列如下:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.
给定A,B,n,请你计算f(n)的值。
输入:包括多组测试,每组测试包括一行3个整数A,B,n(1 <= A, B <=1000, 1 <= n <=100,000,000).以输入3个0表示结束测试,并且不用处理这组。
输出:对每一组测试,每行输出一个f(n)的值。
Sample Input
1 1 3
1 2 10
0 0 0
Sample Output
2
5