Cod sursa(job #135186)
Utilizator | Data | 13 februarie 2008 11:52:42 | |
---|---|---|---|
Problema | Cifra | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<stdio.h>
#include<string.h>
int main()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
char s[101];
int v[20]={0,1,5,2,8,3,9,2,8,7,7,8,4,7,3,8,4,1,5,4};
int n,lung,i,n1,s1,t;
scanf("%d\n",&t);
for(i=1; i<=t; i++)
{
gets(s);
lung=strlen(s);
if(lung==1)
{
n=s[0]-'0';
printf("%d\n",v[n]);
}
else
{
n=10*(s[lung-2]-'0')+(s[lung-1]-'0');
n1=n%20;
n=n/20;
s1=(n*4+v[n1])%10;
printf("%d\n",s1);
}
}
return 0;
}