HDU1005
View Code
1 /* 2 模拟 3 */ 4 #include<stdio.h> 5 int main(){ 6 int a,b,n; 7 int f[ 105 ]; 8 while( scanf("%d%d%d",&a,&b,&n)==3,a+b+n ){ 9 f[1]=1; 10 f[2]=1; 11 //printf("1\n1\n"); 12 for(int i=3;i<=49;i++){ 13 f[i]=f[i-1]*a+f[i-2]*b; 14 f[i]=f[i]%7; 15 //printf("%d\n",f[i]); 16 } 17 n=n%49; 18 if(n==0)n=49; 19 printf("%d\n",f[n]); 20 } 21 return 0; 22 }
关键在于寻找循环节
keep moving...