Pagini recente » Cod sursa (job #2834412) | Cod sursa (job #2684431) | Cod sursa (job #2314390) | Cod sursa (job #1968296) | Cod sursa (job #324155)
Cod sursa(job #324155)
#include <fstream>
#include <cmath>
#include <iostream>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int main()
{
long a[101] = {0};
long i, j, t, rez, x;
for ( i = 1; i < 101; i++)
{
rez = 1;
for(j = 1; j <= i;j++)
{
rez *= i;
rez = rez % 10;
}
a[i] = (rez + a[i-1]) %10;
}
fin >> t;
for ( i = 0 ; i < t; i++)
{
fin >> x;
if ( x > 100)
x = x % 100;
fout << a[x] << '\n';
}
fin.close();
fout.close();
return 0;
}