HDU 1005 Number Sequence
暂不知道怎么办,递归层数过多
Runtime Error
(STACK_OVERFLOW)
#include <iostream> using namespace std; int A, B, n; int func( int x ) { if( x == 1 || x == 2) return 1; else// x > 2 return ( A * func( x - 1 ) + B * func( x - 2 ) ) % 7; } int main() { while( cin >> A >> B >> n ) { if( A==0 && B==0 && n==0 ) break; cout << func(n) << endl; } return 0; } /* Sample 1 1 3 1 2 10 0 0 0 */