Pagini recente » Cod sursa (job #873613) | Cod sursa (job #1612216) | Cod sursa (job #2794004) | Cod sursa (job #2098033) | Cod sursa (job #3219324)
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int uc[100];
int ucif(int x)
{
int rez = 1, pow = x % 4;
if(pow == 0)
pow = 4;
while(pow--)
rez = rez * x % 10;
return rez;
}
void precalc()
{
for(int i = 1; i <= 99; i++)
uc[i] = (uc[i - 1] + ucif(i)) % 10;
}
int main()
{
int T, nrc;
char n[101];
precalc();
fin >> T;
fin.get();
while(T--)
{
fin.getline(n, 101);
nrc = strlen(n);
int x = n[nrc - 1] - '0';
if(nrc > 1)
x += 10 * n[nrc - 2] - '0';
fout << uc[x] << '\n';
}
fin.close();
fout.close();
return 0;
}