Cod sursa(job #366339)
Utilizator | Data | 21 noiembrie 2009 16:07:36 | |
---|---|---|---|
Problema | Cifra | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<stdio.h>
#include<string.h>
int n,c,i,j,v[]={0,1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0},t;
char s[103];
int main()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
scanf("%d\n",&t);
for(j=1;j<=t;++j)
{
gets(s);
n=strlen(s);
c=0;
if(n==1) n=s[n-1]-48;
else
{
n=(s[n-2]-48)*10+(s[n-1]-48);
c=n/20;
n=n%20;
c*=4;
}
for(i=1;i<=n;++i)
c+=v[i];
c=c%10;
printf("%d\n",c);
}
return 0;
}