Cod sursa(job #138268)
| Utilizator | Data | 18 februarie 2008 09:11:16 | |
|---|---|---|---|
| Problema | Koba | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<stdio.h>
#define INPUT "koba.in"
#define OUTPUT "koba.out"
void Rezolvare();
long long unsigned n,a,b,c,aux,suma;
int main()
{
freopen(INPUT,"r",stdin);
freopen(OUTPUT,"w",stdout);
Rezolvare();
return 0;
}
void Rezolvare()
{
int i;
scanf("%llu%llu%llu%llu",&n,&a,&b,&c);
a=a%10;
b=b%10;
c=c%10;
suma=a+b+c;
for(i=4; i<=n; ++i)
{
aux=(c+b*a)%10;
a=b;
b=c;
c=aux;
suma+=aux;
}
printf("%llu",suma);
}
