-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ03007_SoDep2.java
42 lines (42 loc) · 1013 Bytes
/
J03007_SoDep2.java
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
34
35
36
37
38
39
40
41
42
import java.util.*;
public class J03007_SoDep2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
String s = sc.next();
if(check1(s) && check2(s) && check3(s)) System.out.println("YES");
else System.out.println("NO");
}
}
public static boolean check1(String s)
{
char []c = s.toCharArray();
int n = c.length,sum = 0;
for(int i=0;i<n;i++)
{
sum += c[i]-'0';
}
return sum%10==0;
}
public static boolean check2(String s)
{
char []c = s.toCharArray();
int n = c.length;
int l = 0;
int r = n-1;
while(l<r)
if(c[l++]!=c[r--])
return false;
return true;
}
public static boolean check3(String s)
{
char []c = s.toCharArray();
int n = c.length;
int l = 0;
int r = n-1;
return (c[l]=='8' && c[r]=='8');
}
}