Skip to content

Instantly share code, notes, and snippets.

@chenhongqiao

chenhongqiao/golem.java Secret

Last active Mar 6, 2021
Embed
What would you like to do?
import java.util.Scanner;
public class Golem {
public static void main(String[] args) {
// Init Scanner to read from standard input
Scanner sc = new Scanner(System.in);
// Read in n as integer
int n = sc.nextInt();
// Process all n pairs of input
for (int i = 0; i < n; i++) {
// Read in a and b as integers
int a = sc.nextInt();
int b = sc.nextInt();
// Print the larger value of a*b and a+b to standard output
System.out.println(Math.max(a + b, a * b));
}
// Close resource
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment