Cod sursa(job #3365592)

Utilizator dioooooooodionisie tudor dioooooooo Data 22 septembrie 2026 17:55:13
Problema Cifra Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <cstring>
using namespace std;
ifstream cin("cifra.in");
ofstream cout("cifra.out");
int v[21]={0, 1, 5, 2, 8, 3, 9, 8, 8, 9, 5, 8, 4, 9, 5, 2, 6, 5};
int main()
{
    int n;
    string s;
    cin >> n;
    for(int x=1;x<=n;x++)
    {
        cin >> s;
        int m=s.length();
        int nr=0;
        if(m==1) nr=s[0]-'0';
        else
        {
            nr=(s[m-2]-'0')*10+(s[m-1]-'0');
        }
        int suma=nr/20;
        suma*=4;
        nr=nr%20;
        suma+=v[nr];
        cout << suma%10 << '\n';
    }
    return 0;
}