Cod sursa(job #320701)
| Utilizator | Data | 5 iunie 2009 16:29:26 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
unsigned long suma(int n){
unsigned long s=0;
int j;
for (j=1;j<=n;++j)
s+=pow(j,j);
return s;
}
int main()
{
FILE *in,*out;
int *x,t,i;
in=fopen("cifra.in","r");
out=fopen("cifra.out","w");
fscanf(in,"%d",&t);
x=(int*)malloc(t*sizeof(int));
for (i=0;i<t;++i)
{
fscanf(in,"%d",&x[i]);
fprintf(out,"%lu\n",suma(x[i])%10);
}
fclose(in);
fclose(out);
return 0;
}
