Pagini recente » Cod sursa (job #416682) | Cod sursa (job #2190490) | Cod sursa (job #668696) | Cod sursa (job #2327899) | Cod sursa (job #2967282)
#include <bits/stdc++.h>
using namespace std;
/// INPUT / OUTPUT
ifstream fin("cifra.in");
ofstream fout("cifra.out");
/// GLOBAL VARIABLES
int tt;
vector<int>v;
inline int nr(char c)
{
//return c-'1'+1;
if(c == '1')
return 1;
if(c == '2')
return 2;
if(c == '3')
return 3;
if(c == '4')
return 4;
if(c == '5')
return 5;
if(c == '6')
return 6;
if(c == '7')
return 7;
if(c == '8')
return 8;
if(c == '9')
return 9;
return 0;
}
/// READING THE INPUT
int main()
{
ios::sync_with_stdio(false);
fin.tie(NULL);
fout.tie(NULL);
fin >> tt;
v.push_back(1);
for(int i = 2; i <= 100; ++ i)
{
int x = 1;
for(int j = 1; j <= i; ++ j)
{
x=((x % 10) * (i % 10)) % 10;
}
v.push_back((x + v[v.size()-1]) % 10);
}
while(tt--)
{
string num;
fin >> num;
int l = num.length();
l--;
fout << v[nr(num[l - 1]) * 10 + nr(num[l]) - 1] << '\n';
}
}