Cod sursa(job #1379363)
| Utilizator | Data | 6 martie 2015 17:34:24 | |
|---|---|---|---|
| Problema | Cifra | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream f;
ofstream g;
int main()
{
f.open("cifra.in");
g.open("cifra.out");
long long int x,n,t,nr=0,i,j,a,c;
f >> t;
for (a = 1; a <= t;a++)
{
f >> n;
for (i = 1; i <= n; i++)
{
x = 1;
for (j = 1; j <= i; j++)
{
x = x*i;
x = x% 10;
}
x = x % 10;
nr = nr + x;
}
c = nr % 10;
g << c<< endl;
nr = 0;
}
f.close();
g.close();
return 0;
}