1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include<cstdio>
int main() { char str[20]; int Case, i; scanf("%d", &Case); getchar();
while (Case--) { gets(str); bool flag = true; int even = 0, odd = 0;
for (i = 0; i < 19; i++) { if (str[i] == ' ') continue; int n = (str[i] - '0'), digit_sum = 0; if (flag) n *= 2;
while (n) { digit_sum += n % 10; n /= 10; }
if (flag) even += digit_sum; else odd += digit_sum;
flag = !flag; }
int sum = odd + even; if (sum % 10) puts("Invalid"); else puts("Valid"); }
return 0; }
|