Cod sursa(job #2786289)

Utilizator davidg0022Gatea David davidg0022 Data 20 octombrie 2021 17:32:37
Problema Iepuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <fstream>
#include<vector>
using namespace std;

ifstream cin("iepuri.in");
ofstream cout("iepuri.out");

#define LL long long unsigned int

void solve(){
    LL x, y, z, a, b, c, n;
    LL day3, day2, day1;
    cin >> x >> y >> z >> a >> b >> c >> n;
    day3 = x;
    day2 = y;
    day1 = z;
    for (int i = 3; i <= n;i++){
        int aux = (day1 * a) % 666013 + (day2 * b) % 666013 + (day3 * c) % 666013;
        day3 = day2;
        day2 = day1;
        day1 = aux % 666013;
    }
    cout << day1 << '\n';
}

int main(){
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}