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