解题思路:
注意事项:
参考代码:
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < arr.length; i++) { arr[i] = sc.nextInt(); } Arrays.sort(arr); long num = 0; int q = n;//总人数 for (int i = 0; i < arr.length; i++) { q = q-1; num += arr[i]*q; } System.out.println(num); } }
0.0分
2 人评分