Cod sursa(job #330304)

Utilizator LuffyBanu Lavinia Luffy Data 9 iulie 2009 14:58:25
Problema Koba Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<stdio.h>
using namespace std;
long calcul(int n, int t1, int t2, int t3)
{int t4,aux;
long suma;
 n=n-3; suma=t1%10+t2%10+t3%10;
  while(n>0)
 {t1=t1%10; t2=t2%10; t3=t3%10;
  t4=t3+t2*t1; t4=t4%10;
  aux=t1; t1=t2; t2=aux; aux=t2; t2=t3; t3=aux; aux=t3; t3=t4; t4=0;
  suma=suma+t3;
  n--;}
return suma;
}
  
	
int main()
{long n;
int t1,t2,t3;
 FILE *f=fopen("koba.in","r"), *g=fopen("koba.out","w");
 fscanf(f,"%ld%d%d%d",&n,&t1,&t2,&t3);
 fprintf(g,"%ld\n",calcul(n,t1,t2,t3));
fclose(f);
fclose(g);
return 0;
}