Pagini recente » Cod sursa (job #355063) | Cod sursa (job #632130) | Cod sursa (job #1927843) | Cod sursa (job #2607006) | Cod sursa (job #2254569)
#include <cstdio>
using namespace std;
int v[25];
char x, y, z;
int main() {
int t, nr = 0, a, b;
for (int i = 0; i <= 20; i++) {
v[i] = 1;
for (int j = 1; j <= i; j++) {
v[i] = v[i] * i;
v[i] = v[i] % 10; } }
scanf(" %d ", &t);
for (int i = 1; i <= t; i++) {
x = y = z = 'a';
scanf("%c", &z);
while (z != '\n') {
y = x;
x = z;
scanf("%c", &z); }
if (y == 'a') {
for (int j = 1; j <= x - '0'; j++) {
nr = nr + v[j];
nr = nr % 10; } }
else {
nr = (((y - '0') * 10 + x - '0') % 20) * 2;
a = y - '0';
a = a % 2;
b = x - '0';
a = a * 10 + b;
for (int j = 1; j <= a; j++) {
nr = nr + v[j];
nr = nr % 10; } }
printf("%d\n", nr); }
return 0; }