HDU - 4815 Little Tiger vs. Deep Monkey
来源:互联网 发布:c语言面向对象是什么 编辑:程序博客网 时间:2024/05/23 01:23
题目大意:有 A,B 两个人,n 道题目,每题有对应的分数,B 答对题目的概率是 0.5,求 A 不输给 B 的概率不小于 P 要拿的最低分数
解题思路:DP,dp[i][j] 来表示 B 答了前 i 题后分数为 j 的概率,,然后通过 B 的概率求 A 的最低分数
#include <cstdio>#include <cstring>double DP[45][40005];int main() { int T; scanf("%d", &T); while (T--) { int N, MAX, tmp; double P; scanf("%d%lf", &N, &P); memset(DP, 0, sizeof(DP)); DP[0][0] = 1; MAX = 0; for (int i = 0; i < N; i++) { scanf("%d", &tmp); for (int j = 0; j <= MAX; j++) if (DP[i][j] > 0) { DP[i + 1][j] += DP[i][j] * 0.5; DP[i + 1][j + tmp] += DP[i][j] * 0.5; } MAX += tmp; } double sum = 0; for (int j = 0; j <= MAX; j++) { sum += DP[N][j]; if (sum >= P) { printf("%d\n", j); break; } } } return 0;}
0 0
- HDU 4815 Little Tiger vs. Deep Monkey
- hdu 4815 Little Tiger vs. Deep Monkey
- hdu 4815 Little Tiger vs. Deep Monkey
- HDU - 4815 Little Tiger vs. Deep Monkey
- HDU 4815 Little Tiger vs. Deep Monkey
- Little Tiger vs. Deep Monkey HDU
- hdu 4815 Little Tiger vs. Deep Monkey 概率dp
- hdu 4815 Little Tiger vs. Deep Monkey (背包+思维)
- [hdu 4815]Little Tiger vs. Deep Monkey 01背包
- HDU 4815——Little Tiger vs. Deep Monkey
- HDU 4815 Little Tiger vs. Deep Monkey 背包问题
- HDU 4815 Little Tiger vs. Deep Monkey 01背包
- hdu 4815 Little Tiger vs. Deep Monkey(数学+dp)
- 【HDU】4815 - Little Tiger vs. Deep Monkey(母函数)
- HDU 4815 Little Tiger vs. Deep Monkey(母函数)
- -----hdu 4815 -01背包- Little Tiger vs. Deep Monkey
- HDOJ 4815 Little Tiger vs. Deep Monkey
- Little Tiger vs. Deep Monkey
- HDU 1800 Flying to the Mars 字符串哈希||字典树||map
- .NET相关知识点
- 智能硬件爆发之年上游IC厂商是否已经准备好?
- 异步下载图片
- hdu3709 - Balanced Number(2010 Asia Chengdu Regional Contest)数位dp
- HDU - 4815 Little Tiger vs. Deep Monkey
- IOS如何让App运行的时候不进入锁屏状态
- 关于Oracle数据库如何查询非当前用户名命名空间下的表不需要写ower直接from 表名
- ORA-00257 归档程序错误,在释放之前仅限于内部连接
- 谈 C++ 中的 new/delete 和 new[]/delete[]
- android ScrollView嵌套Listview
- 黑马程序员——学习日记之--GUI图形界面学习总结
- UML类图几种关系的总结
- Handler Runnable与Thread的区别详解