Cod sursa(job #710025)

Utilizator lavric_danielLavric Daniel lavric_daniel Data 8 martie 2012 20:02:40
Problema Iepuri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
using namespace std;

long long n,x,y,z,a,b,c,t,v[100],p,w;
int main()
{	
	int i;
	ifstream f("iepuri.in");
	f>>t;
	for(i=1;i<=t;i++)
		{w=0;
			f>>x>>y>>z>>a>>b>>c>>n;
			p=3;
			while(p<=n)
			{w=z*a+y*b+x*c;
			x=y;
			y=z;
			z=w;
			p++;
			}
			v[i]=w;
		}
	f.close();
	ofstream g("iepuri.out");
	for(i=1;i<=t;i++)
		g<<v[i]<<endl;
	g.close();
	return 0;
}