Pagini recente » Cod sursa (job #1082053) | Cod sursa (job #1584847) | Cod sursa (job #848709) | Cod sursa (job #2296766) | Cod sursa (job #2181644)
#include <fstream>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define MODULO 666013
class Task {
public:
void solve() {
//cout <<"111111"<<endl;
rezolvare();
}
private:
int n, x, y, z, a, b, c, n1;
void rezolvare() {
//cout <<"222222"<<endl;
//ifstream fin("/home/nico/CLionProjects/untitled2/iepuri.in");
//ofstream fout("/home/nico/CLionProjects/untitled2/iepuri.out");
ifstream fin("iepuri.in");
ofstream fout("iepuri.out");
fin >> n;
//fin>>n;
//cout <<n <<endl;
//fout <<"dfsd"<<endl;
for (int i = 1; i <= n; i++) {
fin >> x >>y >>z>>a>>b>>c>>n1;
//fout <<x<<" " <<y<<" "<<z<<" "<<a<<" "<<b<<" "<<c<<" "<<n1<<endl;
//cout <<x<<" " <<y<<" "<<z<<" "<<a<<" "<<b<<" "<<c<<" "<<n1<<endl;
fout << get_result()<<"\n";
}
fout.close();
fin.close();
}
int get_result() {
int rez = 0;
for (int i = 3; i <= n1; i++){
rez = ((a * z)% MODULO + (b * y)%MODULO +(c * x)%MODULO)%MODULO;
x = y;
y = z;
z = rez;
}
return rez;
}
};
int main() {
Task task;
//cout <<"dfjsdgf"<<endl;
task.solve();
return 0;
}