https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1311
困難度 ★ 這題就是取平均再依一下去做計數去除以總個數再乘以0.01就是答案了
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
while (n-- != 0) {
int n1 = scn.nextInt(), count = 0;
double tot = 0.0, arr[] = new double[n1];
for (int i = 0; i < n1; i++) {
arr[i] = scn.nextDouble();
tot += arr[i];
}
tot /= n1;
for (int i = 0; i < n1; i++) {
if (arr[i] > tot)
count++;
}
tot = 100 / ((double) n1 / count);
System.out.printf("%.3f%%\n", tot);
}
}
/*
題目:Q10370: Above Average
作者:1010
時間:西元 2016 年 7 月 */
}