Cod sursa(job #1152491)

Utilizator PTAdrian64Pop-Tifrea Adrian PTAdrian64 Data 24 martie 2014 19:22:42
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <cstdio>
#include <queue>

using namespace std;
struct drei
{long x,y,z;
};
queue<drei> q;
long n,a,b,c,t,x,y,z;
drei f;
void Rest()
{
 scanf("%d%d%d%d%d%d%d",&f.x,&f.y,&f.z,&a,&b,&c,&n);
 q.push(f);
 n-=2;
 while(n)
    {z=q.front().z;
     y=q.front().y;
     x=q.front().x;
     f.z=z*a+y*b+x*c;
     f.y=z;
     f.x=y;
     q.push(f);
     q.pop();
     n--;
    }
 printf("%d\n",f.z%666013);
 q.pop();
}

void Solve()
{scanf("%d",&t);
 while(t)
 {Rest();
  t--;
 }
}
int main()
{freopen("iepuri.in","r",stdin);
 freopen("iepuri.out","w",stdout);
 Solve();
 fclose(stdin);
 fclose(stdout);
    return 0;
}