Cod sursa(job #2238909)

Utilizator cory1211Corina cory1211 Data 8 septembrie 2018 13:18:17
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
#define maxim 2000000000
using namespace std;

const long long kMod = 666013;
fstream f("iepuri.in");
ofstream g("iepuri.out");

int main() {

  long long x, y, z, n, a, b, c, i = 0, t, k, aux1, aux2, aux3;
  f >> t;
  for(k = 0; k < t; k++) {
    f >> x >> y >> z >> a >> b >> c >> n;
    long long dp[n];
    dp[0] = x;
    dp[1] = y;
    dp[2] = z;
    //solve(x, y, z, n, a, b, c);
    for(i = 3; i <= n; i++) {
      aux1 = ((dp[i - 1] % kMod) * (a % kMod)) % kMod;
      aux2 = ((dp[i - 2] % kMod) * (b % kMod)) % kMod;
      aux3 = ((dp[i - 3] % kMod) * (c % kMod)) % kMod;
      dp[i] = (aux1 % kMod + (aux2 % kMod + aux3 % kMod) % kMod) % kMod;
    }
    g << dp[n] << endl;
  }
  return 0;
}