-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva787_SimplerOne.java
More file actions
32 lines (29 loc) · 1000 Bytes
/
Uva787_SimplerOne.java
File metadata and controls
32 lines (29 loc) · 1000 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
import java.util.*;
import java.io.*;
import java.math.BigInteger ;
public class Uva787_SimplerOne
{
public static void main(String[] args) throws IOException
{
Scanner sc = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<>();
while( sc.hasNext() ){
BigInteger max = BigInteger.valueOf(Long.MIN_VALUE);
int x = 0 ;
while( ( x = sc.nextInt() ) != -999999 ){
list.add(x);
for(int i = 0 ; i < list.size() ; i++){
BigInteger prod = BigInteger.valueOf(1L);
for(int j = i ; j < list.size() ; j++){
prod = prod.multiply( BigInteger.valueOf(list.get(j)) );
if( prod.compareTo(max) > 0 ){
max = prod ;
}
}
}
}
list.clear();
System.out.println(max.toString());
}
}
}