Pagini recente » Cod sursa (job #2877431) | Cod sursa (job #260569) | Cod sursa (job #2532971) | Cod sursa (job #855133) | Cod sursa (job #2208737)
#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 += 5;
out << s % 10 << '\n';
}
return 0;
}