-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ03007.java
More file actions
33 lines (30 loc) · 876 Bytes
/
J03007.java
File metadata and controls
33 lines (30 loc) · 876 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
33
package CODE_PTIT;
import java.util.Scanner;
public class J03007 {
public static int check1(String s){
if(s.charAt(0) != '8' && s.charAt(s.length()-1) != 8) return 0;
return 1;
}
public static int check2(String s){
int sum1 = 0;
for(int i = 0; i < s.length(); i++){
sum1 += (s.charAt(i) - '0');
}
if(sum1 % 10 == 0) return 1;
return 0;
}
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int t;
t = Integer.parseInt(inp.nextLine());
while(t-- > 0){
String s = inp.nextLine();
if(check1(s) == 1 && check2(s) == 1){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
}