Mai intai trebuie sa te autentifici.
Cod sursa(job #519876)
Utilizator | Data | 6 ianuarie 2011 18:50:53 | |
---|---|---|---|
Problema | Cifra | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include<cstdio>
#include<cstring>
void read(),solve(),preproces();
int T,i,j,u[101],S,L;
char s[110];
int main()
{
read();
preproces();
solve();
return 0;
}
void read()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
scanf("%d",&T);
}
void preproces()
{
for(i=1;i<=100;i++)
{
S=i;
for(j=2;j<=i;j++)
S=(S%10)*i;
u[i]=(S+u[i-1])%10;
}
}
void solve()
{
for(;T;T--)
{
scanf(" %s",s);
L=strlen(s);
if(L==1){printf("%d\n",u[s[0]-'0']);continue;}
printf("%d\n",u[(s[L-2]-'0')*10+s[L-1]-'0']);
}
}