Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哥哥们,这水题咋把我搞得WA了N次了,求原因

Posted by ACMer_Lock at 2011-01-18 10:46:17 on Problem 2350
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator