Cod sursa(job #2871230)

Utilizator LucaMuresanMuresan Luca Valentin LucaMuresan Data 13 martie 2022 18:45:11
Problema Cifra Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in ("cifra.in");
ofstream out ("cifra.out");

int v[] = {-1, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 4, 5};

int main()
{
    int t;
    in >> t;
    while (t--)
    {
        string s;
        in >> s;
        int n = s.size();
        int x;
        if (n>1)
            x = s[n-1] + (s[n-2] - '0') * 10 - '0';
        else
            x = s[n-1] - '0';
        out << v[x%20] << '\n';
    }
    return 0;
}