Cod sursa(job #1073695)

Utilizator apopeid14Apopei Daniel apopeid14 Data 6 ianuarie 2014 18:45:23
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <iostream>
#include <fstream>
 
using namespace std;
fstream fin("iepuri.in", ios::in);
fstream fout("iepuri.out", ios::out);
 
int fib(int x, int y, int z, int a, int b, int c, int n)
{
    int anteprec, med, prec;
    anteprec = x;
    med = y;
    prec = z;
    for(int j = 3; j <= n; j++)
    {
        z = anteprec*c + med*b + prec*a;
        anteprec = med;
        med = prec;
        prec = z;
    }
    return z;
}
 
int main()
{
    int t, x, y, z, a, b, c, n, s;
    const int MOD = 666013;
 
    fin>>t;
    for(int i = 1; i<=t; i++)
    {
        fin>>x>>y>>z>>a>>b>>c>>n;
        s = fib(x, y, z, a, b, c, n);
        fout<<s%MOD<<endl;
    }
 
}