原題鏈接
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); int n; long a; while(cin.hasNext()){ n = cin.nextInt(); a = 1; if(n < 3){ System.out.println(n); continue; } if(n % 2 == 1) a = (long)n * (n-1) * (n-2); else{ if(n % 3 == 0) a = (long)(n-3) * (n-1) * (n-2); else a = (long)n * (n-1) * (n-3); } System.out.println(a); } } }796479 長木 最大的最小公倍數 Accepted 117 1233 java 04-04 17:24:39