Pagini recente » Cod sursa (job #2814744) | Cod sursa (job #670564) | Clasament test12 | Borderou de evaluare (job #2922182) | Cod sursa (job #2103399)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("iepuri.in");
ofstream fout("iepuri.out");
int t,x,y,z,a,b,c,n,i,xx,yy,zz;
int main()
{
fin>>t;
for(i=1;i<=t;i++)
{
fin>>x>>y>>z>>a>>b>>c>>n;
if(n==0) fout<<x;
else if(n==1) fout<<x+y;
else if(n==2) fout<<x+y+z;
else
while(n>2)
{
xx=x;
yy=y;
zz=z;
z=a*zz+b*yy+c*xx;
y=zz;
x=yy;
n--;
}
fout<<z<<'\n';
}
return 0;
}