Cod sursa(job #125644)
Utilizator | Data | 20 ianuarie 2008 15:31:26 | |
---|---|---|---|
Problema | Iepuri | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include<stdlib.h>
#include<stdio.h>
int main()
{ long n, w, x, y, z;
int a, b, c, t, i, j;
freopen("iepuri.in", "r", stdin);
freopen("iepuri.out", "w", stdout);
scanf("%d", &t);
//printf("t=%d\n",t);
for(i=1;i<=t;i++)
{ scanf("%ld%ld%ld%d%d%d%ld", &x, &y,&z,&a,&b,&c,&n);
//printf("%ld,%ld,%ld,%d,%d,%d,%ld", x, y,z,a,b,c,n);
x=x%666013;
y=y%666013;
z=z%666013;
for(j=3;j<=n;j++)
{ w=(c*x%666013+b*y%666013+a*z%666013)%666013;
x=y;
y=z;
z=w;
}
printf("%ld\n",z);
}
return 0;
}