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 |
哪位高手看看呀 为什么总是WA#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator