hdu 1005(规律)

//循环节
#include <cstdio>
#include <iostream>

using namespace std;

int f[49];

int main() {
int i;
f[1] = f[2] = 1;
int a, b, n;
while (scanf("%d%d%d", &a, &b, &n), a+b+n) {
for (i=3; i<49; ++i) f[i] = (a * f[i-1] + b * f[i-2]) % 7;
printf ("%d\n", f[n%48]);
}
return 0;
}

 

posted on 2012-04-03 22:21  Try86  阅读(146)  评论(0)    收藏  举报