-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber_beautiful_2.java
More file actions
30 lines (30 loc) · 937 Bytes
/
Copy pathNumber_beautiful_2.java
File metadata and controls
30 lines (30 loc) · 937 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 Number_beautiful_2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-->0){
String s = in.next();
boolean check1 = true, check2 = true;
int n = s.length();
for(int i=0;i<=n/2;i++){
if(s.charAt(i) != s.charAt(n-i-1)){
check1 = false;
break;
}
}
if(s.charAt(0) != '8' || s.charAt(n-1) !='8' )
check2 = false;
int sum = 0;
for(int i=0;i<n;i++){
sum += Character.getNumericValue(s.charAt(i));
}
if(sum%10 == 0 && check1 == true && check2 == true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
}