Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- BigInteger mul, mx;
- long a, b;
- int i, j, k;
- long[] arr = new long[103];
- Scanner sc = new Scanner(System.in);
- while (sc.hasNext()) {
- a = sc.nextLong();
- if (a == -999999) {
- break;
- }
- arr[1] = a;
- a = sc.nextLong();
- for (k = 1;;) {
- if (a == -999999) {
- break;
- }
- arr[++k] = a;
- a = sc.nextLong();
- }
- b = -9999999;
- mx = BigInteger.valueOf(b);
- for (i = 1; i <= k; i++) {
- mul = BigInteger.valueOf(arr[i]);
- mx = mul.max(mx);
- for (j = i + 1; j <= k; j++) {
- mul = mul.multiply(BigInteger.valueOf(arr[j]));
- mx = mul.max(mx);
- }
- }
- System.out.println("" + mx);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment