Cod sursa(job #1232553)

Utilizator cristinel.casuCasu Cristi cristinel.casu Data 23 septembrie 2014 09:31:55
Problema Iepuri Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>

using namespace std;

#define MAX_MOD 666013

void process()
{
	ifstream input("iepuri.in");
	ofstream output("iepuri.out");
	
	int iter = 0;
	int nSize = 0;
	
	input >> nSize;

	for (iter = 0; iter < nSize; ++iter)
	{
		long long int x, y, z, a, b, c, n, pResult = 0, loop = 0;

		input >> x >> y >> z >> a >> b >> c >> n;
		
		n -= 3;
		
		for (loop = 0; loop <= n; loop++)
		{
			pResult = a * z + b * y + c * x;
			x = y;
			y = z;
			z = pResult % MAX_MOD;
		}
		
		output << (pResult % MAX_MOD) << "\n";
	}

	input.close();
	output.close();
}

int main(int argc, char** argv) 
{
	process();
	return 0;
}