-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ01018.java
More file actions
30 lines (26 loc) · 772 Bytes
/
Copy pathJ01018.java
File metadata and controls
30 lines (26 loc) · 772 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
import java.util.*;
public class J01018 {
public static boolean solve(String s) {
int tong = s.charAt(0) - '0';
for (int i = 1; i < s.length(); i++) {
if (Math.abs(s.charAt(i) - s.charAt(i - 1)) != 2) {
return false;
}
tong += s.charAt(i) - '0';
}
return tong % 10 == 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 (solve(s)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}