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

Why WA ?

Posted by kric at 2007-03-06 16:39:07 on Problem 1862
#include<iostream>
#include<math.h>
#include <iomanip> 
using namespace std;
int partition(int *b,int low,int high)
{
	
	int x,l=low,h=high;
	x=b[low];
	
	while(l!=h)
		
	{
		while(l<h&&b[h]>=x)
		  --h;
		  b[l]=b[h];
	    while(l<h&&b[l]<=x)
		  ++l;
	      b[h]=b[l];

	}
	
	b[l]=x;
		return l;
}
void quicksort(int *a,int i,int j)
{
	if(i<j)
	{
		int pivotpos=partition(a,i,j);
	    quicksort(a,i,pivotpos-1);
	    quicksort(a,pivotpos+1,j);
	}
	
}
int main()
{
    int n,*p,i;
	float t;
	cin>>n;
	if(n>1)
	{
	p=new int [n];
	for(i=0;i<n;i++)
		cin>>p[i];
	quicksort(p,0,n-1);
	t=sqrt(p[n-1]*p[n-2])*2;
	for(i=n-3;i>=0;i--)
	{
		t=2*sqrt(t*p[i]);
	}
	cout<<setiosflags(ios::fixed)<<setprecision(3)<<t<<endl;}
	else cin>>t;
	cout<<setiosflags(ios::fixed)<<setprecision(3)<<t<<endl;
	return 1;
}

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