Cod sursa(job #1012619)
Utilizator | Data | 19 octombrie 2013 13:42:33 | |
---|---|---|---|
Problema | Cifra | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <stdio.h>
#define fr(i,a,b) for(int i=a;i<b;++i)
#define ll long long
int a[10]={0,1,5,2,8,3,9,2,8,7};
int b[10]={0,1,7,0,6,1,7,4,8,7};
int main(){
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
int t;
scanf("%i\n",&t);
fr(i,0,t){
char c1,c2,c3;c1=c2=c3='0';
while(c3!='\n'){
c1=c2;c2=c3;
scanf("%c",&c3);
}
int s=(c1-'0')*7;
if((c1-'0')%2) s+=b[c2-'0'];
else s+=a[c2-'0'];
s=s%10;
printf("%i\n",s);
}
return 0;
}