wenjuice 提交的代码
提交时间:2022 三月 语言:C++运行时间:0ms占用内存:253K
运行状态: Accepted
题目:递推数列1171

登录之后查看代码,点此登录账号

                
                    #include<iostream>
using namespace std;

int main() {
	int a0,a1,a2,p,q,k;
	int mod = 10000;
	while(cin>>a0>>a1>>p>>q>>k) {
		if(k==0) cout<<a0<<endl;
		else if(k==1) cout<<a1<<endl;
		else {
			for(int i=2;i<=k;i++) {
				a2=(q*a0+p*a1)%mod;
				a0=a1;
				a1=a2;
			}
			cout<<a2<<endl;
		}
	}
	return 0;
}