[백준] P4344

동민·2021년 3월 11일
import java.util.Scanner;

public class P4344 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int arr[];
		String[] av;
		double size,avg,sum,count,result;
		int test;

		test = sc.nextInt();
		av = new String[test];

		for (int z = 0; z < test; z++) {

			size = sc.nextInt();
			arr = new int[(int) size];

			sum = 0;
			for (int i = 0; i < (int) size; i++) {

				arr[i] = sc.nextInt();
				sum += arr[i];

			}
			avg = sum / size;

			count = 0;
			for (int k = 0; k < (int) size; k++) {

				if (arr[k] > avg) {
					count++;
				}

			}

			result = count / size;
			result *= 100;
			
			av[z] = String.format("%.3f", result);

		}

		for(String ele : av) {
			
			System.out.println(ele + "%");
			
		}
		
		sc.close();

	}

}
profile
BE Developer

0개의 댓글