Cod sursa(job #1160599)
Utilizator | Data | 30 martie 2014 17:38:22 | |
---|---|---|---|
Problema | Koba | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <cstdio>
using namespace std;
int main()
{
freopen("koba.in","r",stdin);
freopen("koba.out","w",stdout);
int n,t1,t2,t3,tf,i;
long long sol=0;
scanf("%d%d%d%d",&n,&t1,&t2,&t3);
sol=t1%10+t2%10+t3%10;
for(i=4;i<=n;i++)
{
tf=(t3+((t2%10)*(t1%10)))%10;
t1=t2;
t2=t3;
t3=tf;
sol+=tf%10;
}
printf("%lld",sol);
}