1 #include<iostream> 2 #define MAXN 1005 3 #include<stdio.h> 4 using namespace std; 5 6 int _m[MAXN]; 7 8 int main() 9 { 10 //freopen("acm.acm","r",stdin); 11 int num; 12 int a, b, c, d, e, f, g, h, i; 13 int j; 14 cin>>num; 15 while(num --) 16 { 17 cin>>a>>b>>c>>d>>e>>f>>g>>h>>i; 18 _m[0] = a; 19 _m[1] = b; 20 _m[2] = c; 21 for(j = 3; j <= i; ++ j) 22 { 23 if(j%2 != 0) 24 { 25 _m[j] = (g + (d*_m[j-1] + e*_m[j-2] - f*_m[j-3])%g)%g; 26 } 27 if(j%2 == 0) 28 { 29 _m[j] = (h + (f*_m[j-1] - d*_m[j-2] + e*_m[j-3])%h)%h; 30 } 31 } 32 cout<<_m[i]<<endl; 33 } 34 }
时间: 2024-11-14 12:56:41