Pagini recente » Cod sursa (job #1923565) | Cod sursa (job #577658) | Cod sursa (job #1358877) | Cod sursa (job #900671) | Cod sursa (job #757342)
Cod sursa(job #757342)
#include<fstream>
#include<string.h>
using namespace std;
ifstream fin("cifra.in");
ofstream fout("cifra.out");
int T, Nr;
char A[102];
int s[101];
void read()
{
int S = 0;
for(int i = 1; i <= 100; i++)
{
int aux = 1;
for(int j = 1; j <= i; j++)
{
aux = (aux * i) % 10;
}
S = (S+ aux)%10;
s[i] = S;
}
fin>>T;
for(; T; --T)
{
fin >> A;
int n= strlen(A);
if(n<=1)
{
fout<< s[A[0]- '0'];
}
else{
int x = (A[strlen(A) - 2 ] - '0' ) * 10 + A[strlen(A) -1];
fout << s[x];}
fout <<'\n';
}
}
int main()
{
read();
fin.close();
return 0;
}