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

水题。。。。。。。。注意贪心策略就好了

Posted by lvweihua at 2017-08-10 15:34:45 on Problem 1862
#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:
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