Pagini recente » Cod sursa (job #501590) | Cod sursa (job #984070) | Rezultatele filtrării | Cod sursa (job #913098) | Cod sursa (job #997354)
Cod sursa(job #997354)
#include <stdio.h>
#include <string.h>
using namespace std;
char S[110];
int N,T,L[101];
int main()
{
freopen ("cifra.in","r",stdin);
freopen ("cifra.out","w",stdout);
int i,j,x;
for (i=1;i<=100;i++)
{
x=1;
for (j=1;j<=i;j++)
x=x*i%10;
L[i]=(L[i-1]+x)%10;
}
scanf("%d\n",&T);
for (i=1;i<=T;i++)
{
scanf("%s",S);
x=strlen(S);
if (x==1) printf("%d\n",L[S[0]-'0']);
else printf("%d\n",L[(S[x-2]-'0')*10+(S[x-1]-'0')]);
}
fclose(stdin);
fclose(stdout);
return 0;
}