Pagini recente » Cod sursa (job #1188726) | Cod sursa (job #2712911) | Cod sursa (job #1842232) | Cod sursa (job #2767824) | Cod sursa (job #1829431)
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
ifstream fin ("cifra.in");
ofstream fout ("cifra.out");
string s;
int main()
{
int n, cnt = 0, j = 1, num;
fin >> n;
for (int k = 0; k < n; ++k) {
cnt = 0, j = 1;
fin >> s;
if (s.size() > 1)
num = (s[s.size() - 2] - 48) * 10 + (s[s.size() - 1] - 48);
else
num = s[0] - 48;
for (int i = 1; i <= num; ++i) {
if (j == 1)
++cnt;
if (j == 2) {
if (i % 4 == 2)
cnt += 4;
else
cnt += 6;
}
if (j == 3) {
if (i % 4 == 3)
cnt += 7;
else
cnt += 3;
}
if (j == 4)
cnt += 6;
if (j == 5)
cnt += 5;
if (j == 6)
cnt += 6;
if (j == 7) {
if (i % 4 == 1)
cnt += 7;
else
cnt += 3;
}
if (j == 8)
cnt += 6;
if (j == 9)
cnt += 9;
++j;
if (j == 10)
j = 0;
}
fout << cnt % 10 << "\n";
}
return 0;
}