Cod sursa(job #243483)
Utilizator | Data | 13 ianuarie 2009 10:23:47 | |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
// koba.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
int main()
{
int t,i;
int a,b,c,e,n;
FILE *f1,*f2;
f1=fopen("koba.in","r");
f2=fopen("koba.out","w");
fscanf(f1,"%d %d %d %d",&n,&c,&b,&a);
a=a%10;
b=b%10;
c=c%10;
t=a+b+c;
for(i=4;i<=n;i++)
{
e=a;
a=(a+b*c)%10;
c=b;
b=e;
t=t+a;
}
fprintf(f2,"%d",t);
fclose(f1);
fclose(f2);
return 0;
}