Cod sursa(job #1066758)

Utilizator petretiberiu46Petre Tiberiu petretiberiu46 Data 25 decembrie 2013 16:24:19
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 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;

    fin>>t;
    for(int i = 1; i<=t; i++)
    {
        fin>>x>>y>>z>>a>>b>>c>>n;
        fout<<fib(x, y, z, a, b, c, n)<<endl;
    }

}