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,现在选出一个子集,使得这些人恰好出一个题的概率 ...
随机推荐
- 「NOIP2016」愤怒的小鸟
传送门 Luogu 解题思路 首先这个数据范围十分之小啊. 我们考虑预处理出所有可以带来贡献的抛物线 三点确定一条抛物线都会噻 然后把每条抛物线可以覆盖的点状压起来,然后状压DP随便转移就好了. 有一 ...
- IOS 常用View属性设置
设置按钮属性 1.设置按钮背景颜色 backgroundColor @property (weak, nonatomic) IBOutlet UIButton *deleteButton; self. ...
- 5.8 Nginx 常用功能的配置
- C# FTp 上传,下载
public class FtpHelper { string ftpServerIP; string ftpRemotePath; string ftpUserID; string ftpPassw ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 图片:响应式图片
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- LR的深入理解资料汇集
今天面试被问到LR的算法的梯度和正则化项,自己不太理解,所以找了一些相关资料,发现LR的算法在梯度下降,正则化和sigmoid函数方面都有很深的研究,期间也发现一些比较好的资料,记录一下. 这篇论文推 ...
- PHP代码审计之入门实战
系统介绍 CMS名称:新秀企业网站系统PHP版 官网:www.sinsiu.com 版本:这里国光用的1.0 正式版 (官网最新的版本有毒,网站安装的时候居然默认使用远程数据库???迷之操作 那站长的 ...
- qq群的表设计探究
2018年3月21日 课题组管理就如qq的群是一样的,课题组有课题组组长:qq群有群主:课题组有组员:qq群有群人员 对于一个课题组来说,组长可以对课题组进行修改,组员只能看得见,但是不能修改.所以 ...
- SSH和SFTP的简单使用
ssh命令 ssh 命令用来远程登录linux主机:ssh username@hostname 默认端口是22,如果设定了其他端口,那么使用-p参数来指明,例如端口若改为6666, 则登录命令变为 s ...
- Asp.net禁用site.Mobile.Master
RT,在asp.net新的项目中遇到的一个问题.项目使用了Boostrap后网页打开是正常的,但是换成移动端打开这个网页的时候就奇怪了.很多样式不见了.原来是自动切换到了site.Mobile.Mas ...