Cod sursa(job #227593)
| Utilizator | Data | 4 decembrie 2008 22:09:37 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include<stdio.h>
long long get_me_last(int a)
{
long long aux;
aux=a%10;
for(int i=1;i<=a-1;++i)
aux=(aux*a)%10;
return aux;
}
int main()
{
long long n,ult,coef=0;
int t;
freopen("cifra.in","r",stdin);
freopen("cifra.out","w",stdout);
t=0;
scanf("%d\n",&t);
n=0;
while(t)
{
scanf("%d\n",&n);
ult=n%20;
coef=n/20*20;
int sum=0;
for(int i=1+coef;i<=n;++i)
{
sum+=get_me_last(i);
if(sum>10)
sum%=10;
}
printf("%d\n",sum);
--t;
}
return 0;
}