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

大牛看看,java怎么过不了啊

Posted by n55iw at 2011-08-12 14:36:04 on Problem 1862
import java.text.DecimalFormat;
import java.util.*;
import java.math.*;
public class aa {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int N=cin.nextInt(),i,j;
		double []a=new double[N+1];
		for(i=0;i<N;i++) a[i]=cin.nextDouble();
		for(i=0;i<N;i++)
			for(j=i+1;j<N;j++)
				if(a[i]>a[j])
				{
					double temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
      //  for(i=0;i<N;i++) 
		//System.out.println(a[i]);
		double result=a[N-1];
		for(i=N-2;i>0;i--)
		{
			result=2*Math.sqrt(result*a[i]);
		}
		String parten = "#0.000";
		DecimalFormat decimal = new DecimalFormat(parten);
		String re = decimal.format(result);
       System.out.println(re);
		
		
	}

}

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