Cod sursa(job #516185)
| Utilizator | Data | 23 decembrie 2010 12:55:56 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.97 kb |
#include <stdio.h>
int main()
{
int n=0,s=0,i=0,j=0,x=0;
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
scanf("%d",&n);
for (i=0; i<n; ++i)
{
scanf("%d",&x);
s=0;
for (j=1; j<=x; ++j)
{
if (j%10==1) s+=1;
else if (j%10==4) s+=6;
else if (j%10==5) s+=5;
else if (j%10==6) s+=6;
else if (j%10==9) s+=9;
else if (j%10==2 || j%10==8)
{
if (j%4==0) s+=6;
if (j%4==2) s+=4;
}
else if (j%10==3)
{
if (j%4==1) s+=3;
if (j%4==3) s+=7;
}
else if (j%10==7)
{
if (j%4==1) s+=7;
if (j%4==3) s+=3;
}
s%=10;
}
printf("%d\n",s);
}
return 0;
}
