题解 | #递推数列#
递推数列
https://www.nowcoder.com/practice/d0e751eac618463bb6ac447369e4aa25
#include <iostream> using namespace std; int main() { int a0,a1,p,q,k; cin>>a0>>a1>>p>>q>>k; int arr[k+1]; arr[0] = a0; arr[1] = a1; for(int i =2;i<=k;i++){ arr[i] = (p*arr[i-1]+q*arr[i-2])%10000; } cout<<arr[k]<<endl; } // 64 位输出请用 printf("%lld")