Pagini recente » Cod sursa (job #1605755) | Cod sursa (job #1357643) | Cod sursa (job #791375) | Cod sursa (job #2324686) | Cod sursa (job #3286061)
#include <fstream>
#include <vector>
#include <string>
using namespace std;
ifstream f("iepuri.in");
ofstream g("iepuri.out");
const long long mod = 666013;
void solv()
{
long long x, y, z, a, b, c, n;
f >> x >> y >> z >> a >> b >> c >> n;
for(long long i = 3; i <= n; i ++)
{
long long d = (((1LL * z * a) % mod + (1LL * y * b) % mod) % mod + (1LL * x * c) % mod) % mod;
x = y; y = z; z = d;
}
g << z << '\n';
}
int main()
{
long long t; f >> t;
for(; t >= 1; t --)
solv();
return 0;
}