Editorial for Game


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.
by: donchominkov

Sample solutions:

Video in BG

JavaScript

let [x, y, z] = gets();

[x, y, z] = [+x, +y, + z];

const best = Math.max(
    x + y + z,
    x + y * z,
    x * y + z,
    x * y * z
);

print(best);

Java

import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String n = in.nextLine();

    int x = n.charAt(0) - '0';
    int y = n.charAt(1) - '0';
    int z = n.charAt(2) - '0';

    int result = -1;

    result = Math.max(result, x + y + z);
    result = Math.max(result, x + y * z);
    result = Math.max(result, x * y + z);
    result = Math.max(result, x * y * z);

    System.out.println(result);
  }
}

Comments