Cod sursa(job #137399)
Utilizator | Data | 17 februarie 2008 11:57:44 | |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp | Status | done |
Runda | preONI 2008, Runda 4, Clasele 5-8 | Marime | 0.35 kb |
#include<stdio.h>
long n,t1,t2,t3,c,s;
int main()
{
freopen("koba.in","r",stdin);
freopen("koba.out","w",stdout);
scanf("%ld",&n);
scanf("%ld %ld %ld",&t1,&t2,&t3);
s=(t1%10+t2%10+t3%10);
n=n-3;
while(n)
{
c=s;
s+=(t3%10+((t2%10)*(t1%10))%10)%10;
t1=t2%10;
t2=t3%10;
t3=(s-c)%10;
n--;
}
printf("%ld",s);
return 0;
}