Pagini recente » Cod sursa (job #149324) | Cod sursa (job #2804636) | Cod sursa (job #353366) | Cod sursa (job #93633) | Cod sursa (job #2578644)
#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 --;
int x, y , z, a, b, c, n;
in >> x >> y >> z >> a >> b >> c >> n;
int dr = 0;
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;
}
out << dr << endl;
}
}
in.close();
out.close();
return 0;
}