Cod sursa(job #2220620)

Utilizator crion1999Anitei cristi crion1999 Data 12 iulie 2018 11:29:38
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <iostream>
#include <fstream>
using namespace std;
int mat[3][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[1][0] = x;
        mat[1][1] = y;
        mat[1][2] = z;
        for(int i = 3; i <= n; ++i)
        {
            mat[2][0] = mat[1][1];
            mat[2][1] = mat[1][2];
            mat[2][2] = mat[1][0] * c + mat[1][1] * b + mat[1][2] * a;
            mat[1][0] = mat[2][0];
            mat[1][1] = mat[2][1];
            mat[1][2] = mat[2][2];
        }
        fo << mat[2][2] << '\n';
        t--;
    }
}