看题偷瞄到题解2333(以为是劲题呢。。结果是乱贪心,奇怪)

排序之后,如果加入下一个比现在更优就更新答案(奇怪啊)

t=ans*(1-a[i])+s*a[i];(ans*(1-a[i])是新的一位不选的概率(即到这位之前已经选好)+选这位(即s*a[i])(s是以前都不选的概率))

 #include<bits/stdc++.h>
#define LL long long
#define LD long double
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
double ans,s,a[N];
int main()
{
int n=ra();
for (int i=; i<=n; i++)
scanf("%lf",&a[i]);
sort(a+,a+n+);
s=-a[n]; ans=a[n];
for (int i=n-; i>=; i--)
{
double t=ans*(-a[i])+s*a[i];
if (t>ans) ans=t;
else break;
s*=(-a[i]);
}
printf("%.12lf",ans);
return ;
}

cf442 B.Andrey and Problem的更多相关文章

  1. codeforces 442B B. Andrey and Problem(贪心)

    题目链接: B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. cf442B Andrey and Problem

    B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. codeforces#253 D - Andrey and Problem里的数学知识

    这道题是这种,给主人公一堆事件的成功概率,他仅仅想恰好成功一件. 于是,问题来了,他要选择哪些事件去做,才干使他的想法实现的概率最大. 我的第一个想法是枚举,枚举的话我想到用dfs,但是认为太麻烦. ...

  4. Codeforces Round #253 (Div. 1) B. Andrey and Problem

    B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. Codeforces 442B Andrey and Problem(贪婪)

    题目链接:Codeforces 442B Andrey and Problem 题目大意:Andrey有一个问题,想要朋友们为自己出一道题,如今他有n个朋友.每一个朋友想出题目的概率为pi,可是他能够 ...

  6. Andrey and Problem

    B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. Codeforces 442B. Andrey and Problem

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. 【codeforces 442B】 Andrey and Problem

    http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的 ...

  9. [CF442B] Andrey and Problem (概率dp)

    题目链接:http://codeforces.com/problemset/problem/442/B 题目大意:有n个人,第i个人出一道题的概率是pi,现在选出一个子集,使得这些人恰好出一个题的概率 ...

随机推荐

  1. JavaScript函数用法

    本文我们来学习下js函数的一些用法. 上图的要点为: 1.函数具有属性,如foo.length和foo.name. 2.arguments是类数组,arguments.length为实参的数目. 3. ...

  2. ThreadLocal的原理和在框架中的应用

    ThreadLocal的原理和在框架中的应用 博客分类: java基础 框架多线程SpringthreadDAO  概述      我们知道Spring通过各种DAO模板类降低了开发者使用各种数据持久 ...

  3. Commons BeanUtils 中对Map的操作

    CSDN学院招募微信小程序讲师啦 程序员简历优化指南! [观点]移动原生App开发 PK HTML 5开发 云端应用征文大赛,秀绝招,赢无人机! Commons BeanUtils 中对Map的操作 ...

  4. SciPy 积分

    章节 SciPy 介绍 SciPy 安装 SciPy 基础功能 SciPy 特殊函数 SciPy k均值聚类 SciPy 常量 SciPy fftpack(傅里叶变换) SciPy 积分 SciPy ...

  5. win10安装mysql过程&&链接过程&&备份和导入数据&&grant命令

    win10安装mysql过程&&链接过程&&备份和导入数据&&grant命令   一 .安装 一开始在mysql官网(https://www.mysql ...

  6. HTML学习第七天(二)

    HTML学习第七天(二) 新增的非主体结构 header元素 footer元素 hgroup元素 address元素 header元素:通常用于存放整个页面或页面内的一个区域块的标题,但也可以存放类似 ...

  7. vs2010编译C++ 运算符

    // CTest.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include &l ...

  8. HihoCoder 1246:王胖浩与环

    #1246 : 王胖浩与环 时间限制:6000ms 单点时限:1000ms 内存限制:256MB 描述 王胖浩有一个环,环上有n个正整数.他有特殊的能力,能将环切成k段,每段包含一个或者多个数字. 对 ...

  9. VUE - mapState 辅助函数(简化)

    1,第一种 <template>   <div id="app">     <p> {{count}} </p>     <p ...

  10. Oracle 的DBA考证

    转自 :https://www.cnblogs.com/chunge2050/archive/2013/04/16/3023730.html 详细的了解了几天之后,总结起来就是oracle为DBA认证 ...