/* UVa */
/*****************************************************************************/
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
ArrayList<Integer> n=new ArrayList<Integer>();
while (sc.hasNext()) {
int c=sc.nextInt();
if (c!=-999999) {
n.add(c);
continue;
}
BigInteger m=BigInteger.valueOf(c);
BigInteger p=BigInteger.valueOf(0);
for(int i=0; i<n.size(); i++) {
p=BigInteger.valueOf(1);
for(int j=i; j<n.size(); j++) {
p=p.multiply(BigInteger.valueOf(n.get(j)));
if(p.compareTo(m)==1) {
m=p;
}
}
}
System.out.println(m.toString());
n.clear();
}
}
}
/*****************************************************************************/
UVa 787
this is a straight O(n**2) solution, which relies on java's BitInteger...
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment