Cod sursa(job #485920)

Utilizator Teodor94Teodor Plop Teodor94 Data 19 septembrie 2010 21:35:38
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include<cstdio>

int n,t1,t2,t3,t4,s;

void rez()
{
	scanf("%d%d%d%d",&n,&t1,&t2,&t3);
	t1%=10;
	t2%=10;
	t3%=10;
	s=t1+t2+t3;
	for (int i=4;i<=n;++i)
	{
		t4=t3+t2*t1;
		t4%=10;
		t1=t2;
		t2=t3;
		t3=t4;
		s+=t4;
	}
	printf("%d",s);
}

int main()
{
	freopen("koba.in","r",stdin);
	freopen("koba.out","w",stdout);
	rez();
	return 0;
}