Pagini recente » Cod sursa (job #1867802) | Cod sursa (job #1344921) | Rating Mihai Holban (mikita) | Cod sursa (job #1896972) | Cod sursa (job #1519602)
#include <fstream>
#include <cstring>
#include <algorithm>
#include <vector>
#define infile "cifra.in"
#define outfile "cifra.out"
using namespace std;
vector<int> precalc;
char test[105];
void _precalc(void) {
precalc.resize(100, 0);
for (int index = 1; index < 100; ++index) {
int temp = 1;
for (int step = 1; step <= index; ++step) {
temp = (temp * index) % 10;
}
precalc[index] = (precalc[index - 1] + temp) % 10;
}
}
int main() {
_precalc();
ifstream fin(infile);
ofstream fout(outfile);
int testCount;
fin >> testCount;
while (testCount--) {
fin >> test;
int query = 0;
if (strlen(test) == 1)
query = test[0] - '0';
else
query = (test[strlen(test) - 2] - '0') * 10 + (test[strlen(test) - 1] - '0');
fout << precalc[query] << '\n';
}
return 0;
}
//Trust me, I'm the Doctor!