-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ03040
31 lines (27 loc) · 920 Bytes
/
J03040
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
package test;
import java.util.Scanner;
public class J03040 {
public static int Check(String s) {
if (s.charAt(1) > s.charAt(0) && s.charAt(2) > s.charAt(1) && s.charAt(3) > s.charAt(2) && s.charAt(4) > s.charAt(3))
return 1;
if (s.charAt(1) == s.charAt(0) && s.charAt(2) == s.charAt(1) && s.charAt(4) == s.charAt(3))
return 1;
for (int i = 0; i < 5; i++) {
if (s.charAt(i) != '6' && s.charAt(i) != '8')
return 0;
}
return 1;
}
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().substring(5).replace(".", "");
if (Check(s) == 1)
System.out.println("YES");
else
System.out.println("NO");
}
}
}