Cod sursa(job #1884312)
Utilizator | Data | 18 februarie 2017 17:03:46 | |
---|---|---|---|
Problema | Cifra | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <stdio.h>
#include <cstring>
using namespace std;
char s[102],a,b,c;
char sum[20]={1,4,7,6,5,6,3,6,9,0,1,6,3,6,5,6,7,4,9,0};
int t,i,n,j,rez;
int main()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
scanf("%d%c",&t,&s[0]);
for(i=1;i<=t;i++){
a=b=rez=0;
fgets(s, 102, stdin);
n = strlen(s);
if(n>=3)
a=s[n-3]-'0';
b=s[n-2]-'0';
c=a*10+b;
rez=c/20*4;
for(j=0;j<c%20;j++)
rez+=sum[j];
printf("%d\n",rez%10);
}
return 0;
}