Cod sursa(job #333773)

Utilizator iulia609fara nume iulia609 Data 23 iulie 2009 20:28:35
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<stdio.h>
using namespace std;

int main()
{ int t1,t3,t2,t4;
  long long n,i,s;

	FILE *f = fopen("koba.in", "r");
	FILE *g = fopen("koba.out", "w");
	
	n = 0;
	fscanf(f, "%lld", &n);
	fscanf(f, "%d%d%d",&t1,&t2, &t3);
	
	t1 = t1%10;
	t2 = t2%10;
	t3 = t3%10;
	s = t1+t2+t3;
	for(i = 4; i <= n; i++)
		{
			t4 = (t3 + (t1*t2)%10)%10;
			t1 = t2;
			t2 = t3;
			t3 = t4;
			s += t4;
		}
	
	fprintf(g, "%lld\n", s);
	
	fclose(f);
	fclose(g);
	return 0;
}