Cod sursa(job #84706)

Utilizator gabitzish1Gabriel Bitis gabitzish1 Data 16 septembrie 2007 14:37:10
Problema Iepuri Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<stdio.h>

long long aux, x, y, z, a, b, c, t;
long long n, contor;


void calcul()
{
  freopen("iepuri.in","r",stdin);
  freopen("iepuri.out","w",stdout);
  scanf("%lld",&t);
  int i;
  for (i=1; i<=t; i++)
    {
      contor=3;
      scanf("%lld%lld%lld%lld%lld%lld%lld",&x,&y,&z,&a,&b,&c,&n);
      while (contor<=n)
	{
	  contor++;
	  aux=x;
	  x=y%666013; y=z%666013;
	  z=((a*y)%666013+(b*x)%666013+(c*aux)%666013)%666013;
	}
      printf("%lld\n",z);
    }
}

int main()
{
  calcul();
  return 0;
}