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 |
Re:哪位高手看看呀 为什么总是WAIn Reply To:哪位高手看看呀 为什么总是WA Posted by:00448322 at 2005-04-07 17:13:08 > #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; > } > } #include <iostream> #include <math.h> #include <iomanip> using namespace std; int cmp(const void *a,const void *b) { return -(*(int*)a-*(int*)b); } int main() { int num[100]; int n; int i; double sum; while(cin>>n) { for(i=0;i<n;i++) cin>>num[i]; if(n==1) { cout<<fixed<<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<<fixed<<setprecision(3)<<sum<<endl; } return 0; } 改的你的,过了 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator