Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哥哥们,这水题咋把我搞得WA了N次了,求原因import java.text.DecimalFormat; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int sum,count; double[] res = new double[n]; for (int i = 0; i < n; i++) { int m = scan.nextInt(); int[] input = new int[m]; sum=0; for(int j=0;j<m;j++){ input[j] = scan.nextInt(); sum+=input[j]; } count =0; for(int j=0;j<m;j++){ if(input[j]*m>sum){ count++; } } res[i]=(double)count*100/m; } for (int i = 0; i < n; i++) { System.out.println(new DecimalFormat("00.000").format(res[i])+"%"); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator