Cod sursa(job #2220618)

Utilizator crion1999Anitei cristi crion1999 Data 12 iulie 2018 11:26:29
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <iostream>
#include <fstream>
using namespace std;
int mat[100005][3];
ifstream fi("iepuri.in");
ofstream fo("iepuri.out");
int main()
{
    int t;
    fi >> t;
    int x, y, z, a, b, c, n;
    while(t)
    {
        fi >> x >> y >> z >> a >> b >> c >> n;
        mat[2][0] = x;
        mat[2][1] = y;
        mat[2][2] = z;
        for(int i = 3; i <= n; ++i)
        {
            mat[i][0] = mat[i-1][1];
            mat[i][1] = mat[i-1][2];
            mat[i][2] = mat[i-1][0] * c + mat[i-1][1] * b + mat[i-1][2] * a;
        }
        fo << mat[n][2] << '\n';
        t--;
    }
}