Pagini recente » Cod sursa (job #1106349) | Cod sursa (job #894130) | Cod sursa (job #3255499) | Cod sursa (job #1393269) | Cod sursa (job #1157121)
#include <cstdio>
#include <cstring>
using namespace std;
int sp[105];
char s[105];
int main()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
int n,prod,nrc,x;
scanf("%d\n",&n);
sp[0]=0;
for(int i=1;i<100;i++){
prod=1;
for(int j=1;j<=i;j++){
prod=(prod*i)%10;
}
sp[i]=(sp[i-1]+prod)%10;
}
for(int i=1;i<=n;i++){
gets(s+1);
s[0]='0';
nrc=strlen(s+1);
x=(s[nrc-1]-'0')*10+(s[nrc]-'0');
printf("%d\n",sp[x]);
}
return 0;
}