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 |
Why WA ?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator