-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathSrangeLottery.java
More file actions
39 lines (33 loc) · 1.27 KB
/
Copy pathSrangeLottery.java
File metadata and controls
39 lines (33 loc) · 1.27 KB
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
package srange_lottery;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;
public class SrangeLottery {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new FileReader("input.txt"));
String number = sc.nextLine();
char[] ch = number.toCharArray();
BigInteger min = new BigInteger("0");
for(int i = 1; i < ch.length; i++){
if(i + 1 <= number.length()){
String strOne = number.substring(0, i) + number.substring(i+1);
if(!strOne.substring(0,1).equals("0")){
for(int j = 0; j < strOne.length(); j++){
String strTwo = (strOne.substring(0, j) + strOne.substring(j+1));
if(!strTwo.substring(0,1).equals("0")){
BigInteger str = new BigInteger(strTwo);
if(min.compareTo(str) < 0){
min = str;
}
}
}
}
}
}
FileWriter out = new FileWriter("output.txt");
out.write(String.valueOf(min));
out.close();
}
}