数学思路:乘法的定义为多个加法,当包含1的时候,乘法才小于加法。
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(a == 1 || b == 1){ System.out.println((a + b) * c); }else if(c == 1){ System.out.println(a * (b + c)); }else{ System.out.println(a * b * c); } } }