Cod sursa(job #250235)
Utilizator | Miu Alexandra alexamiu2008 | Data | 30 ianuarie 2009 13:48:03 |
---|---|---|---|
Problema | Koba | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<stdio.h>
FILE*fin,*fout;
unsigned long int s,i,u1,u,u2,u3,tpp,tp,tppp,tcurent,t1,t2,t3,n;
int main(){
fin=fopen("koba.in","r");
fout=fopen("koba.out","w");
fscanf(fin,"%ld %ld %ld %ld",&n,&t1,&t2,&t3);
s=0;
tp=t3;tpp=t2; tppp=t1; s=t1%10+t2%10+t3%10;
for(i=4;i<=n;i++){
tcurent=tp+tpp*tppp;
u=tcurent%10;
s=s+u;
tppp=tpp;tpp=tp; tp=tcurent;
}
fprintf(fout,"%ld",s);
fclose(fin);
fclose(fout);
return 0;
}