Cod sursa(job #2812323)

Utilizator andrei_laurentiuRadu Andrei-Laurentiu andrei_laurentiu Data 4 decembrie 2021 13:18:52
Problema Iepuri Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <iostream>
#include <fstream>
#define mod 666013
#define ll long long
using namespace std;

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

int answear(int x, int y, int z, int a, int b, int c, int n)
{
    int ans;
    x %= mod;
    y %= mod;
    z %= mod;
    ans = z;
    n -= 2;
    while(n)
    {
        ans = ((a * z) % mod + (b * y) % mod + (c * x) % mod) % mod;
        x = y;
        y = z;
        z = ans;
        --n;
    }
    return ans;
}
int main()
{
    int x, y, z, a, b, c, n, t, i;
    fin>>t;

    for(i = 1; i <= t; ++i)
    {
        fin>>x>>y>>z>>a>>b>>c>>n;
        fout<<answear(x, y, z, a, b, c, n)<<'\n';
    }
    return 0;
}