| ||||||||||
| 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 | |||||||||
水题。。。。。。。。注意贪心策略就好了#include<cstdio> //贪心策略是最大的和次大的不断碰撞,直到剩下一个为止
#include<algorithm>
#include<cmath>
using namespace std;
const int MAXN=105;
int S[MAXN],N;
double W[MAXN];
int main()
{
while(scanf("%d",&N)!=EOF){
double w=0.0;
for(int i=0;i<N;i++)
scanf("%d",&S[i]);
for(int i=0;i<N;i++)
W[i]=1.0*S[i];
sort(W,W+N);
while(N>=2){
W[N-2]=2*sqrt(W[N-1]*W[N-2]);
sort(W,W+N-1);
N--;
}
printf("%.3f\n",W[0]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator