-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ03008.java
More file actions
32 lines (28 loc) · 863 Bytes
/
Copy pathJ03008.java
File metadata and controls
32 lines (28 loc) · 863 Bytes
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
import java.util.*;
public class J03008 {
public static boolean check(String s) {
int l = 0;
int r = s.length() - 1;
while (l < r) {
if (s.charAt(l) != s.charAt(r) || s.charAt(l) == '0' || s.charAt(l) == '1' || s.charAt(l) == '4' || s.charAt(l) == '6' || s.charAt(l) == '8' || s.charAt(l) == '9') {
return false;
}
l++;
r--;
}
return true;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
while (n-- > 0) {
String s = sc.nextLine();
if (check(s)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}