import java.util.Scanner;
/**
- Created by mac on 2018/12/1.
*/
public class Main {
public static void main(String[]args){
Scanner input = new Scanner(System.in);
int a,b,n;
while(true){
a = input.nextInt();
b = input.nextInt();
n = input.nextInt();
if (a < 1 & a > 1000 & b < 1 & b > 1000 & b < 1 & a > 100000000)
System.exit(0);
if (a == 0 && b ==0 && n == 0) break;
int f[] = new int[50];
for (int i = 1; i < 50; i++) {
if (i == 1 || i == 2) {
f[i] = 1;
} else {
f[i] = (a * f[i - 1] + b * f[i - 2]) % 7;
}
}
System.out.println(f[n % 49]);
}
input.close();
}
}
网友评论