-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ03024
34 lines (30 loc) · 869 Bytes
/
J03024
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
package test;
import java.util.Scanner;
public class J03024 {
public static int check(String x){
int c = 0;
int l = 0;
int d = 0;
for(int i = 0; i < x.length(); i++){
if(x.charAt(i) < '0' || x.charAt(i) > '9') return -1;
else{
if((x.charAt(i) - '0')%2 == 0) c++;
else l++;
}
d++;
}
if(d%2==0 && c>l) return 1;
else return 0;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while(t-- >0){
String s = sc.nextLine();
if(check(s) == -1) System.out.println("INVALID");
else if(check(s) == 0) System.out.println("NO");
else System.out.println("YES");
}
}
}