hdu4815Little Tiger vs. Deep Monkey 概率dp
来源:互联网 发布:视频观看软件 编辑:程序博客网 时间:2024/06/08 01:24
//给n(<=40)个数ai(<=1000)//猴每次0.5的概率得到ai这个分数//问人最少需要多少值才能在概率至少大于p的情况比//猴的分数大#include<cstdio>#include<cstring>#include<iostream>using namespace std ;const int maxn = 4e4+10 ;double dp[maxn] ;int main(){ int t ; scanf("%d" , &t) ; while(t--){ int n ; double p ; scanf("%d%lf" ,&n , &p) ; memset(dp , 0 , sizeof(dp)) ; dp[0] = 1 ; for(int i = 1;i <= n;i++){ int c ; scanf("%d" , &c) ; for(int j = maxn-1;j >= c;j--){ dp[j] = dp[j-c]*0.5 + dp[j]*0.5; } for(int j = c-1;j >= 0;j--){ dp[j]*=0.5 ; } } double sum = 0 ; int ans = 0 ; for(int j = 0;j < maxn;j++){ sum += dp[j] ; if(sum >= p){ ans = j ; break ; } } printf("%d\n" , ans) ; } return 0 ;}
0 0
- hdu4815Little Tiger vs. Deep Monkey 概率dp
- HDU4815Little Tiger vs. Deep Monkey(01背包)
- hdu 4815 Little Tiger vs. Deep Monkey 概率dp
- HDOJ 4815 Little Tiger vs. Deep Monkey(概率DP)
- hdu 4815 Little Tiger vs. Deep Monkey DP(概率类 较简单)
- hdu4815- Little Tiger vs. Deep Monkey-概率dp或者背包计数
- Little Tiger vs. Deep Monkey
- Little Tiger vs. Deep Monkey
- HDOJ 4815 Little Tiger vs. Deep Monkey(简单DP)
- hdu 4815 Little Tiger vs. Deep Monkey(数学+dp)
- [hdu4815]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
- 机器学习笔记_数学基础_4-线性代数
- C++基础::shared_ptr 编程细节(一)
- 【Unity开发】NGUI,UGUI按钮监听的动态添加与移除
- Linux图片处理工具-GraphicsMagick
- 32位和64位系统区别及字节对齐
- hdu4815Little Tiger vs. Deep Monkey 概率dp
- POJ 2001 Shortest Prefixes (字典树模拟切割)
- MongoDB C# / .NET Driver 中IMongoQuery的内部实现Query的用法
- iOS 图片 按钮 切圆角
- UIlabel多行文字自动换行 (自动折行)
- Qt程序启动画面播放(gif与swf两种动画格式) - 路上的脚印
- 碎碎念:工作上的挑战和机遇etc.
- 八数码2
- ngModel双向绑定的一些问题