Cod sursa(job #2480083)

Utilizator MatteoalexandruMatteo Verzotti Matteoalexandru Data 24 octombrie 2019 21:03:32
Problema Cifra Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.54 kb
/*
                `-/oo+/-   ``
              .oyhhhhhhyo.`od
             +hhhhyyoooos. h/
            +hhyso++oosy- /s
           .yoooossyyo:``-y`
            ..----.` ``.-/+:.`
                   `````..-::/.
                  `..```.-::///`
                 `-.....--::::/:
                `.......--::////:
               `...`....---:::://:
             `......``..--:::::///:`
            `---.......--:::::////+/`
            ----------::::::/::///++:
            ----:---:::::///////////:`
            .----::::::////////////:-`
            `----::::::::::/::::::::-
             `.-----:::::::::::::::-
               ...----:::::::::/:-`
                 `.---::/+osss+:`
                   ``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>

using namespace std;

const int INF = 2e9;

int v[105] = {0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4};
char s[105];

int main()
{
    freopen("cifra.in", "r", stdin);
    freopen("cifra.out", "w", stdout);
    int t;
    char ch;
    for(int i = 20; i <= 101; i++){
        v[i] = (v[i - 1] + v[i % 20]) % 10;
    }
    scanf("%d ", &t);
    while(t--){
        fgets(s, 102, stdin);
        int n = strlen(s) - 1;
        int nr;
        if(n >= 2) nr = (s[n - 2] - '0') * 10 + (s[n - 1] - '0');
        else nr = s[0] - '0';
        printf("%d\n", v[nr]);
    }
    return 0;
}