Pagini recente » Cod sursa (job #1815538) | Cod sursa (job #2085743) | Diferente pentru problema/algoritm intre reviziile 16 si 15 | Cod sursa (job #2089143) | 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;
}