Cod sursa(job #275312)
Utilizator | A Andrei AnDrEwBoY | Data | 10 martie 2009 13:09:34 |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include<stdio.h>
#include<math.h>
int main()
{
freopen("cifre.in","r",stdin);
freopen("cifre.out","w",stdout);
int n,t,cifra;
scanf("%d",&t);
for(int i = 1; i <= t;i++)
{
cifra = 0;
scanf("%d",&n);
for(int j = 1; j <= n; j++)
{
cifra += (long long int)pow(j,j) % 10;
if(cifra >= 10) cifra %= 10;
}
printf("%d\n",cifra);
}
fclose(stdin); fclose(stdout);
return 0;
}