-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ01010.java
More file actions
34 lines (30 loc) · 932 Bytes
/
J01010.java
File metadata and controls
34 lines (30 loc) · 932 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
34
package CODE_PTIT;
import java.util.Scanner;
public class J01010 {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int t = Integer.parseInt(inp.nextLine());
while(t-- > 0){
String s = inp.nextLine();
int ans = 0, ok = 1;
for(int i = 0; i < s.length(); i++){
if(s.charAt(i) == '1'){
ans = ans * 10 + 1;
}
else if(s.charAt(i) == '0' || s.charAt(i) == '8' || s.charAt(i) == '9'){
ans = ans * 10;
}
else {
ok = 0;
break;
}
}
if(ok == 0 || ans == 0){
System.out.println("INVALID");
}
else{
System.out.println(ans);
}
}
}
}