Pagini recente » Cod sursa (job #2005267) | Cod sursa (job #1414535) | Cod sursa (job #3352599) | Cod sursa (job #3353030) | Cod sursa (job #3351089)
#include <bits/stdc++.h>
using namespace std;
int ans[21];
void solve()
{
int t;
cin >> t;
for (int i = 1; i <= 20; i++)
{
int x = 1;
for (int j = 1; j <= i; j++)
{
x = (x * i) % 10;
}
ans[i] = (ans[i - 1] + x) % 10;
}
while (t--)
{
string s;
cin >> s;
int n = 0;
if (s.size() == 1)
{
n = s[0] - '0';
}
else
{
n = (s[s.size() - 2] - '0') * 10 + (s[s.size() - 1] - '0');
}
n %= 20;
cout << ans[n] << "\n";
}
}
signed main()
{
#ifdef LOCAL
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
#else
freopen("cifra.in", "r", stdin);
freopen("cifra.out", "w", stdout);
#endif // LOCAL
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long tt;
tt = 1;
while (tt--)
{
solve();
}
return 0;
}