Pagini recente » Cod sursa (job #760800) | Cod sursa (job #1224182) | Cod sursa (job #2514719) | Cod sursa (job #1954316) | Cod sursa (job #2252099)
#include <fstream>
#include <string>
std::ifstream fin("cifra.in");
std::ofstream fout("cifra.out");
const int lastDigitNN[10] = {0, 1, 4, 7, 6, 5, 6, 3, 6, 9};
int main() {
int T;
fin >> T;
while (T--) {
std::string x;
fin >> x;
int sizeOfx = x.size(), number, lastDigit = 0;
if (sizeOfx > 1) {
number = std::stoi(x.substr(sizeOfx - 2));
}
else {
number = std::stoi(x);
}
for (int i = 0; i <= number; ++i) {
lastDigit += lastDigitNN[i % 10];
lastDigit %= 10;
}
fout << lastDigit << "\n";
}
return 0;
}