Pagini recente » Cod sursa (job #1561357) | Cod sursa (job #1688504) | Cod sursa (job #489995) | Cod sursa (job #1850935) | Cod sursa (job #2208735)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("cifra.in");
ofstream out("cifra.out");
int main()
{
int t, n;
in >> t;
for(int i = 1; i <= t; i ++)
{
in >> n;
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((n / 10) % 2 == 1)
s += 5;
out << s << '\n';
}
return 0;
}