/C06021 - Số ưu thế
<Problem>
https://code.ptit.edu.vn/student/question/C06021#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <ctype.h>
int main() {
int t;
scanf("%d", &t);
getchar();
while (t--) {
char s[1001];
gets(s);
bool check = true;
if (s[0] == '0') check = false;
else {
for (int i = 0; i < strlen(s); i++) {
if (s[i] < '0' || s[i] > '9') {
check = false;
break;
}
}
}
if (!check) {
printf("INVALID\n");
continue;
}
int even = 0;
int odd = 0;
for (int i = 0; i < strlen(s); i++) {
if ((s[i] - 48) % 2 == 0) even++;
else odd++;
}
if ((even > odd) && (strlen(s) % 2 == 0)
|| (odd > even) && (strlen(s) % 2 == 1)) printf("YES");
else printf("NO");
printf("\n");
}
return 0;
}