Cod sursa(job #3158450)

Utilizator Allie28Radu Alesia Allie28 Data 18 octombrie 2023 19:10:55
Problema Iepuri Scor 0
Compilator cpp-64 Status done
Runda HLO 2023 - Cls 11-12 - Tema 0 Marime 0.54 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("iepuri.in");
ofstream fout("iepuri.out");

const int LMAX = 5005;

int main(){
    short t;
    int a,b,c,n;
    fin>>t;
    for (int i = 0; i < t; i++) {
        int v[3];
        fin>>v[0]>>v[1]>>v[2]>>a>>b>>c>>n;
        for (int j = 3 ; j <= n; j++) {
            v[j%3] = v[(j-1)%3] * a + v[(j-2)%3] * b + v[(j-3)%3] * c;
        }
        fout<<v[n%3]<<endl;
    }



    fin.close();
    fout.close();
    return 0;
}