输入A B n ,f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7 难点:1.题目n会达到10亿,如果单纯用递归,空间不够用,所以得发现规律 #includeusing namespace std;int f(int a, int b, int n){ if (n == 1 || n == 2) return 1; else return (a*f(a, b, n - 1) + b*f(a, b, n - 2))%7;}int main( ){ int a, b, n; cin >> a >> b >> n; while (a!=0 || b!=0 || n!=0) { n = n % 49; cout << f(a, b, n)< > a >> b >> n; } return 0;}