Cod sursa(job #235437)
Utilizator | Data | 23 decembrie 2008 22:02:18 | |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include <stdio.h>
int main()
{
FILE *in = fopen("koba.in","r");
FILE *out = fopen("koba.out","w");
int n,t1,t2,t3,x,s;
fscanf(in,"%d%d%d%d",&n,&t1,&t2,&t3);
t1 = t1%10;
t2 = t2%10;
t3 = t3%10;
s = t1+t2+t3;
n=n-3;
while (n)
{
n--;
x = t3+t2*t1;
t1 = t2;
t2 = t3;
t3 = x%10;
s += t3;
}
fprintf(out,"%d",s);
}