Cod sursa(job #299446)

Utilizator tudgal1001Profir Tudor tudgal1001 Data 6 aprilie 2009 19:40:33
Problema Koba Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.3 kb
#include<fstream.h>

ifstream f("koba.in");
ofstream g("koba.out");

int main ()
{
	long long n,t1,t2,t3,t4,s,i;
	f>>n>>t1>>t2>>t3;
	i=3; s=t1%10+t2%10+t3%10;
	while (i<n)
	{
		t1%=10; t2%=10; t3%=10;
		t4=t3+(t1*t2);
		s+=t4%10;
		t1=t2;
		t2=t3;
		t3=t4;
		i++;
	}
	g<<s;
	return 0;
}