Cod sursa(job #222536)

Utilizator TrumpCardPopescu Silviu TrumpCard Data 23 noiembrie 2008 11:49:48
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <stdio.h>
#include <math.h>
int t;
long n;
int cifra(long x)
{return (int)pow(x,x)%10;}
int main()
{
freopen("cifra.in", "r", stdin);
freopen("cifra.out", "w", stdout);
scanf("%d", &t);
for(int i=0;i<t;i++) {scanf("%ld", &n);
                      int s=0;
                      for(int j=1;j<=n;j++) s+=cifra(j);
                      s=s%10;
                      printf("%d\n", s);
                      }
fclose(stdin);
fclose(stdout);
}