标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 125495 Accepted Submission(s):
30510
1 1 3 1 2 10 0 0 0
2 5
1 #include <stdio.h> 2 int num[55] ; //数组开的要大于 i 最大值 ; 3 int main() 4 { 5 int a,b,c,i,temp ; 6 num[1] = 1 ; num[2] = 1 ; 7 while(~scanf("%d %d %d",&a, &b, &c) , (a || b || c) ) 8 { 9 10 for(i=3; i<=49; i++) 11 { 12 num[i] = (a*num[i-1] + b*num[i-2]) %7 ; 13 if(num[i] == num[i-1] && num[i] == 1 ) 14 break ; 15 } 16 temp = i-2 ; 17 c = c%temp ; 18 if(c == 0) 19 printf("%d\n",num[temp]) ; // 一直理解错,取余后得到0为循环最后一个,不是第一个; 20 else 21 printf("%d\n", num[c]) ; 22 } 23 return 0 ; 24 }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4634038.html