bzoj1419: Red is good
来源:互联网 发布:linux设置为中文后死机 编辑:程序博客网 时间:2024/04/30 11:39
传送门
显然的dp呀。
设f[i][j]表示还剩i张红,j张黑时的最有收益。
转移很好yy:f[i][j]=max(0,i/(i+j)(f[i-1][j]+1)+j/(i+j)(f[i][j-1]-1))
然后这题卡内存,要开滚存。
#include<cmath>#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>using namespace std;double f[2][5050];int n,m,c;double cal(double x){ return x<0?0:x;}int main(){ scanf("%d%d",&n,&m); c=0; for (int i=0;i<=n;i++){ f[c][0]=i; for (int j=1;j<=m;j++) f[c][j]=cal(1.0*i/(i+j)*(f[c^1][j]+1)+1.0*j/(i+j)*(f[c][j-1]-1)); c^=1; } long long ans=floor(f[n&1][m]*1e6); printf("%lld.%06lld",ans/1000000,ans%1000000);}
阅读全文
0 0
- bzoj1419: Red is good
- Bzoj1419 Red is good
- 【bzoj1419】Red is good 期望dp
- [bzoj1419]Red is good 期望DP
- 【BZOJ1419】Red is good 期望DP
- BZOJ1419:Red is good(期望DP)
- 【BZOJ1419】【期望DP】Red is good 题解
- 【期望DP】BZOJ1419[Red is good]题解
- [BZOJ1419]Red is good(概率期望dp)
- [BZOJ1419]Red is good 数学期望动态规划
- Red is good (DP)
- [HbFS-]Red is good
- [HbFS-]Red is good
- oj_470 Red is good
- Red is good
- bzoj 1419: Red is good
- BZOJ 1419 Red is good
- BZOJ 1419: red is good
- 观察者模式 Observer Pattern
- 了解Oracle RAC Brain Split Resolution集群脑裂协议
- 在XML中为layout设置阴影
- 模拟分页,FIFO,LRU,OPT算法
- Web常见漏洞简介
- bzoj1419: Red is good
- JAVA与数据库
- 单例模式
- netfilter/iptables学习总结(一)
- 给学习Linux系统小白的两三个建议
- adaboost原理图解
- 使用Maven搭建Struts2+Spring3+Hibernate4的整合开发环境
- 树莓派GPS(USB转串口)获取经纬度
- 1179: 构造表达式