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;…
题目链接: B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help.…
B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He ca…
这道题是这种,给主人公一堆事件的成功概率,他仅仅想恰好成功一件. 于是,问题来了,他要选择哪些事件去做,才干使他的想法实现的概率最大. 我的第一个想法是枚举,枚举的话我想到用dfs,但是认为太麻烦. 于是想是不是有什么规律,于是推导了一下,推了一个出来,写成代码提交之后发现是错的. 最后就没办法了,剩下的时间不够写dfs,于是就放弃了. 今天看thnkndblv的代码,代码非常短,于是就想肯定是有什么数学规律,于是看了一下, 果然如此. 是这种,还是枚举,当然是有技巧的,看我娓娓道来. 枚举的话…
B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He ca…
题目链接:Codeforces 442B Andrey and Problem 题目大意:Andrey有一个问题,想要朋友们为自己出一道题,如今他有n个朋友.每一个朋友想出题目的概率为pi,可是他能够同一时候向多个人寻求帮助.只是他仅仅能要一道题,也就是假设他向两个人寻求帮助,假设两个人都成功出题,也是不能够的. 解题思路:贪心,从概率最大的人開始考虑.假设询问他使得概率变大,则要询问. #include <cstdio> #include <cstring> #include &…
B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He ca…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to…
http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的概率最大. Solution 很显然的概率dp,过了样例即可AC..话说我为什么要刷B题→_→ 代码 // codeforces442B #include<algorithm> #include<iostream> #include<cstdlib> #include<…
题目链接:http://codeforces.com/problemset/problem/442/B 题目大意:有n个人,第i个人出一道题的概率是pi,现在选出一个子集,使得这些人恰好出一个题的概率最大.问最大概率. 可以仿照背包问题来做,即每个人可问可不问. f[i][j]代表从前i个人里问j个人所获得1个题的最大概率. f[i][j] = max{ f[i-1][j], f[i-1][j-1]*(1-p[i])+z[i-1][j-1]*p[i] }; z[i][j]为从前i个人里问j个人所…