Cod sursa(job #1200399)
| Utilizator | Data | 22 iunie 2014 13:59:08 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int putere(int x);
int suma(int a);
int main()
{
int t,n;
f >> t;
for(int i = 1; i <= t; i++)
{
f >> n;
g << suma(n) << '\n';
}
f.close();;
g.close();
return 0;
}
int putere(int x)
{
return pow(x,x);
}
int suma(int a)
{
long long s = 0;
for(int j = 1; j <= a; j++)
s += putere(j);
return s%10;
}
