cf442 B.Andrey and Problem
看题偷瞄到题解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的更多相关文章
- codeforces 442B B. Andrey and Problem(贪心)
题目链接: B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input ...
- cf442B Andrey and Problem
B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- codeforces#253 D - Andrey and Problem里的数学知识
这道题是这种,给主人公一堆事件的成功概率,他仅仅想恰好成功一件. 于是,问题来了,他要选择哪些事件去做,才干使他的想法实现的概率最大. 我的第一个想法是枚举,枚举的话我想到用dfs,但是认为太麻烦. ...
- 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 ...
- Codeforces 442B Andrey and Problem(贪婪)
题目链接:Codeforces 442B Andrey and Problem 题目大意:Andrey有一个问题,想要朋友们为自己出一道题,如今他有n个朋友.每一个朋友想出题目的概率为pi,可是他能够 ...
- Andrey and Problem
B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces 442B. Andrey and Problem
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【codeforces 442B】 Andrey and Problem
http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的 ...
- [CF442B] Andrey and Problem (概率dp)
题目链接:http://codeforces.com/problemset/problem/442/B 题目大意:有n个人,第i个人出一道题的概率是pi,现在选出一个子集,使得这些人恰好出一个题的概率 ...
随机推荐
- 三 进制、精度,Java的类型转换
进制的表示: 0b010 : 二进制表示形式:前面+0n 0100 : 八进制表示形式: 前面+0 0x001 : 16进制表示形式:前面+0x 计算机以补码的方式进行运算 进制的转换: 10进制 ...
- 2018--Linux面试题
1.企业场景面试题:buffer与Cache的区别. 2.企业场景面试题:redhat与CentOS的区别. 3.企业场景面试题: 描述RAID 0 1 5 10的特点. 4.企业场景面试题:32位 ...
- 设备树DTS 学习:3-常用的DTS 函数
Linux内核中目前DTS相关的函数都是以of_前缀开头的,它们的实现位于内核源码的drivers/of下面 void __iomem*of_iomap(struct device_node *nod ...
- 实验吧——Recursive
环境:win10,kali虚拟机 工具:ida 虚拟机打开看看,发现是ELF文件,运行一下,额没有什么发现. Ida打开看看,发现是在文件内部运行python解释器,百度搜索了一个基本上可以找到Py_ ...
- spingboot2.0外部引入xml配置文件时找不到文件等报错
之前的项目可以启动,后面不知道为什么都不行了,报错如下: SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found bindin ...
- windows下安装多台mysql数据库且实现主从复制
版本如下: windows server 2012 R2 mysql server 5.7.25安装版 / mysql server 5.7.25 解压版 * 这里为啥还要有安装版和解压版勒,主要是因 ...
- 关于AlertDialog多选框中全选和反选的实现办法
package mobile.android.ch07.multi.choice.dialog; import android.app.Activity; import android.app.Ale ...
- 机器学习(ML)八之正向传播、反向传播和计算图,及数值稳定性和模型初始化
正向传播 正向传播的计算图 通常绘制计算图来可视化运算符和变量在计算中的依赖关系.下图绘制了本节中样例模型正向传播的计算图,其中左下角是输入,右上角是输出.可以看到,图中箭头方向大多是向右和向上,其中 ...
- 7.1 Varnish VCL
根据以上的配置增加集群,修改default.vcl # This ) # man page for details on VCL syntax and semantics. # # Default b ...
- wav文件与byte互转 C#
//wav转byte public void WavToByte() { Byte[] bs; FileStream fs = new FileStream(@"C:\1.wav" ...