//土尔逊Torson 编写于2023/05/20 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> using namespace std; int Math_ak(int a0, int a1, int p, int q, int k) { int ak = 0; for (int i = 1; i < k; ++i) { ak = a1*p + a0*q; ak %= 10000; a0 = a1; a1 = ak; } return ak; } int main() { int a0, a1, p, q, k; scanf("%d%d%d%d%d", &a0, &a1, &p, &q, &k); int answer = Math_ak(a0, a1, p, q, k); printf("%d\n", answer); system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")