Pagini recente » Clasament eusebiu_oji_2011_cls9 | Cod sursa (job #566797) | Cod sursa (job #1569617) | Cod sursa (job #1508524) | Cod sursa (job #2578649)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("iepuri.in");
ofstream out("iepuri.out");
class curs{
static int x;
int j;
public:
curs(){j = 0;}
static void init(int i){x = i;}
void show(){
cout << x << endl;
}
};
int curs :: x; /// define x
int main()
{
unsigned int T;
in >> T;
while (T){
T --;
long long x,y,z,a,b,c, dr = 0;
int n;
in >> x >> y >> z >> a >> b >> c >> n;
if (n == 0)
out << x << endl;
else if (n == 1)
out << y << endl;
else if (n == 2)
out << z << endl;
else{
dr = a*z + b*y + c*x;
n -= 3;
while (n > 0){
n --;
x = y;
y = z;
z = dr;
dr = ((a*z)%666013 + (b*y) % 666013+ (c*x)%666013)%666013;
}
out << dr << endl;
}
}
in.close();
out.close();
return 0;
}