Cod sursa(job #7751)
Utilizator | Data | 22 ianuarie 2007 13:12:49 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include<stdio.h>
int main()
{
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
long long unsigned n,t,i=0,putere,j2,s=0,j;
scanf("%llu",&t);
for(i=0;i<t;++i)
{
scanf("%llu",&n);
s=0;
for(j=1;j<=n;++j)
{
j2=j;
putere=1;
while(putere<j)
{
j2*=j;
j2%=10;
++putere;
}
s+=j2%10;
}
printf("%llu\n",s%10);
}
return 0;
}