Cod sursa(job #1100021)

Utilizator andi23roscaRosca Andrei andi23rosca Data 6 februarie 2014 15:22:34
Problema Iepuri Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <cstdio>
using namespace std;
int main() {
freopen("iepuri.in","r",stdin);
freopen("iepuri.out","w",stdout);
int t,i;
unsigned long long int n,v[3][4],x=0;
scanf("%ld",&t);
for(i=1;i<=t;i++) {
    scanf("%lld %lld %lld %lld %lld %lld %lld",&v[1][1],&v[1][2],&v[1][3],&v[2][3],&v[2][2],&v[2][1],&n);
    while(n!=2) {
        x=(v[1][1]*v[2][1]+v[1][2]*v[2][2]+v[1][3]*v[2][3])%666013;
        v[1][1]=v[1][2];
        v[1][2]=v[1][3];
        v[1][3]=x;
        n--;
    }
    printf("%ld\n",x);
}
return 0;
}