RE了,怎么解决?
http://acm.hdu.不能单纯递归啊
#include<stdio.h> int main() { long n , A , B , i , a[49] ; while( scanf("%ld%ld%ld", &A , &B , &n ) ) { if( A == 0 && B == 0 && n == 0 ) break ; a[1] = 1 ; a[2] = 1 ; for( i = 3 ; i < 49 ; i++ ) a[i] = ( A * a[i-1] + B * a[i-2] ) % 7 ; printf("%ld\n", a[n%48] ) ; } }递归的话肯定栈溢出,找循环节然后迭代