Pagini recente » Cod sursa (job #2219004) | Cod sursa (job #715623) | Cod sursa (job #257617) | Cod sursa (job #1641251) | Cod sursa (job #2196157)
#include <iostream>
#include <fstream>
#include <vector>
#define modulo 666013
#define nmax 200000000
using namespace std;
ifstream fin("iepuri.in");
ofstream fout("iepuri.out");
int N;
int x,y,z,a,b,c;
int main()
{
int T;
fin>>T;
while(T--)
{
fin>>x>>y>>z>>a>>b>>c>>N;
N=N-2;//avem deja calculate primele
while(N--)
{
int rez=(a*z+b*y+c*x)%666013;
x=y;
y=z;
z=rez;
}
fout<<z<<'\n';
}
return 0;
}