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

Posted by 00448322 at 2005-04-07 17:13:08 on Problem 1862
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;

int cmp(const void *a,const void *b)
{
	return -(*(int*)a-*(int*)b);
}

void main()
{
	int num[100];
	int n;
	int i;
	double sum;
	cin>>n;
	cout<<setiosflags(ios::fixed);
	while(cin)
	{
		for(i=0;i<n;i++)
			cin>>num[i];
		if(n==1)
		{	
			cout<<setprecision(3)<<double(num[0])<<endl;
			continue;
		}
		qsort(num,n,sizeof(int),cmp);
		sum=2*sqrt(double(num[0]*num[1]));
		for(i=2;i<n;i++)
			sum=2*sqrt(double(sum*num[i]));
		cout<<setprecision(3)<<sum<<endl;
		cin>>n;
	}
}

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