-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
SeparatetheNumbers.java
31 lines (29 loc) · 1.03 KB
/
SeparatetheNumbers.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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int q = in.nextInt();
label:for(int a0 = 0; a0 < q; a0++){
String s = in.next();
// int mid = s.length()/2;
for(int i=1;i<s.length();i++){
BigInteger initial = new BigInteger(s.substring(0,i));
//int initial = Integer.parseInt(s.substring(0,i));
int pos = i;
while(s.indexOf(initial.add(new BigInteger("1")).toString(),pos-1)==pos){
pos+=initial.add(new BigInteger("1")).toString().length();
initial = initial.add(new BigInteger("1"));
}
if(pos==s.length()){
System.out.println("YES "+s.substring(0,i));
continue label;
}
}
System.out.println("NO");
}
}
}