Cod sursa(job #2254099)
Utilizator | Data | 4 octombrie 2018 19:39:30 | |
---|---|---|---|
Problema | Cifra | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <fstream>
#include <string>
ifstream cin("cifra.in");
ofstream cout("cifra.out");
const int lastDigitOfS20[20] = {0,1,5,2,8,3,9,2,8,7,7,8,4,7,3,8,4,1,5,4};
const int difference[5] = {0, 4, 8, 2, 6};
int main() {
int T;
cin >> T;
while (T--) {
std::string x;
cin >> x;
int sizeOfx = x.size(), number;
if (sizeOfx > 1) {
number = std::stoi(x.substr(sizeOfx - 2));
}
else {
number = std::stoi(x);
}
cout << (difference[number / 20] + lastDigitOfS20[number % 20]) % 10 << "\n";
}
return 0;
}