Cod sursa(job #1569920)

Utilizator iDanyelArvat Ovidiu Daniel iDanyel Data 16 ianuarie 2016 00:20:39
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>
#define m 666013;
using namespace std;

int main()
{
    ifstream f("iepuri.in");
    ofstream g("iepuri.out");
    int t, x, y, z, a, b, c, n, i, j;
    f >> t;
    for(i=1;i<=t;i++)
    {
        f >> x >> y >> z >> a >> b >> c >> n;
        int v[n];
        for(j=0;j<=n;j++)
        {
            if(j<3)
            {
                if(j==0) v[j]=x;
                if(j==1) v[j]=y;
                else v[j]=z;
            }
            else
            {
                v[j]=(v[j-1]*a+v[j-2]*b+v[j-3]*c)%m;
            }
        }
        g << v[n] << endl;
    }
    f.close();
    g.close();
    return 0;
}