Cod sursa(job #791558)

Utilizator ana.zetg wea tw ana.z Data 24 septembrie 2012 16:23:09
Problema Koba Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.28 kb
#include<fstream.h>
int n,t1,t2,t3,c,i,s;
int main()
{
	ifstream in("koba.in");
	ofstream out("koba.out");
	in>>n>>t1>>t2>>t3;
	t1=t1%10;
	t2=t2%10;
	t3=t3%10;
	s=t1+t2+t3;
	for(i=4;i<=n;i++)
	{
		c=t3;
		t3=(t3+t2*t1)%10;
		s+=t3;
		t1=t2;
		t2=c;
	}
	out<<s;
}