Pagini recente » Cod sursa (job #2982446) | Cod sursa (job #2716633) | Cod sursa (job #1834906) | Cod sursa (job #1514715) | Cod sursa (job #2208742)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("cifra.in");
ofstream out("cifra.out");
int main()
{
int t;
in >> t;
for(int i = 1; i <= t; i ++)
{
string x;
in >> x;
int n = (x[x.size() - 1] - '0');
int s = 0;
for(int j = 1; j <= n % 10; j ++)
{
int t = 1;
for(int h = 1; h <= j; h ++)
t = (t * j) % 10;
s += t;
s = s % 10;
}
if(x.size() % 2 == 0)
s += 7;
out << s % 10 << '\n';
}
return 0;
}