Cod sursa(job #1777782)
| Utilizator | Data | 12 octombrie 2016 21:18:53 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <cstdio>
#include <cmath>
using namespace std;
FILE * fin = fopen("cifra.in", "r");
FILE * fout = fopen("cifra.out", "w");
int cifra(int x)
{
int s=0, j;
for(int i=1;i<=x;i++)
{
j=i%10;
s+=pow(j,i);
}
return s%10;
}
int main()
{
int t, x, y;
fscanf(fin, "%d", &t);
while(t--)
{
fscanf(fin, "%d", &x);
y=cifra(x);
fprintf(fout, "%d", y);
fprintf(fout, "%c", '\n');
}
return 0;
}
