-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ01010.java
46 lines (42 loc) · 1.38 KB
/
J01010.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
43
44
45
46
import java.util.*;
import java.math.*;
public class J01010 {
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();
StringBuilder sb = new StringBuilder("");
boolean check = true;
for (int i = 0; i < s.length(); i++) {
char tmp = s.charAt(i);
if (tmp == '0' || tmp == '8' || tmp == '9') {
sb.append('0');
} else if (tmp == '1') {
sb.append('1');
} else {
check = false;
break;
}
}
if (!check) {
System.out.println("INVALID");
} else {
boolean check_After = false;
for (char i : sb.toString().toCharArray()) {
if (i != '0') {
check_After = true;
break;
}
}
if (!check_After) {
System.out.println("INVALID");
} else {
BigInteger x = new BigInteger(sb.toString());
System.out.println(x);
}
}
}
}
}