[hdu4815]Little Tiger vs. Deep Monkey
来源:互联网 发布:网络语泰迪是什么梗 编辑:程序博客网 时间:2024/06/02 15:08
概率DP,长春现场赛的题,当时没看,现在补上...
f[i][j]代表答对前i道题得j分的概率
转移方程f[i][j]+=f[i-1][j]/2;f[i][j+a[i]]+=f[i-1][j]/2; a[i]是第i道题的分数
#include <iostream>#include<cstdio>#include<cstring>using namespace std;int T,a[40010],n;double p,f[50][40010];int main(){ scanf("%d",&T); for(int Ti=1;Ti<=T;Ti++) { scanf("%d %lf",&n,&p); for (int i=1;i<=n;i++) scanf("%d",&a[i]); memset(f,0,sizeof(f)); f[0][0]=1; for(int i=1;i<=n;i++) { for (int j=0;j<=40000-a[i];j++) { f[i][j]+=f[i-1][j]/2; f[i][j+a[i]]+=f[i-1][j]/2; } } double t=0; int ans=0; for(int i=0;i<=40000;i++) { if (t<p) {t+=f[n][i];ans=i;} else break; } printf("%d\n",ans); } return 0;}
0 0
- [hdu4815]Little Tiger vs. Deep Monkey
- HDU4815 Little Tiger vs. Deep Monkey (母函数应用)
- 【01背包求方案数】HDU4815-Little Tiger vs. Deep Monkey
- hdu4815- Little Tiger vs. Deep Monkey-概率dp或者背包计数
- Little Tiger vs. Deep Monkey
- Little Tiger vs. Deep Monkey
- HDU 4815 Little Tiger vs. Deep Monkey
- HDOJ 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
- HDOJ 4815 Little Tiger vs. Deep Monkey(简单DP)
- 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
- 设计和实现回合制战斗系统
- Java设计模式(写在前面的话)
- JAVA设计模式初探之装饰者模式
- 8. UIDocumentInteractionController
- iphone开发资源汇总
- [hdu4815]Little Tiger vs. Deep Monkey
- USACO 3.2.2:Stringsobits
- gcc编译c++程序
- Q24:二叉搜索树的后序遍历序列
- SSD1306 OLED 驱动
- 泛型
- 远程监控之图形处理杂谈
- hdu1505 暴力或dp优化
- Linux 命令行学习(持续更新中)