LanQiaoTestCodes/寻找三个数的最大乘积3.java

26 lines
601 B
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package LanQiaoOJ;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Ñ°ÕÒÈý¸öÊýµÄ×î´ó³Ë»ý3 {
static int N=1010;
static int []a=new int [N];
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
ArrayList<Integer>list=new ArrayList<>();
for(int i=0;i<n;i++) {
int x=sc.nextInt();
list.add(x);
}
Collections.sort(list);
int ans=list.get(n-1)*list.get(n-2)*list.get(n-3);
ans=Math.max(ans, list.get(0)*list.get(1)*list.get(n-1));
System.out.print(ans);
}
}