Cod sursa(job #2442171)
Utilizator | Data | 23 iulie 2019 01:34:21 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <fstream>
using namespace std;
ifstream cin("cifra.in");
ofstream cout("cifra.out");
int v[10];
int main()
{
for(int i=1; i<=9; i++)
{
int sum=i;
int county=i%4;
if(county==0)
county=4;
while(--county)
sum*=i;
v[i]=v[i-1]+sum%10;
}
int t;
cin >> t;
for(int i=0; i<t; i++)
{
string s;
cin >> s;
int lastie=int(s[s.size()-1]-'0'),bestie=0;
if(s.size()>=2)
{
bestie=int(s[s.size()-2]-'0');
}
cout <<(v[lastie]+v[9]*bestie)%10 <<'\n';
}
return 0;
}