打气球(记忆化dp+数学期望)
来源:互联网 发布:php httpclient 编辑:程序博客网 时间:2024/05/17 10:43
过于菜QAQ
#include <cstdio>#include <iostream>#include <iomanip>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>using namespace std;inline int R(){ char t=getchar();int o=0;bool F=0; while(t<48||t>57)F|=t==45,t=getchar(); for(;t<58&&t>47;t=getchar())o=(o<<1)+(o<<3)+t-48; return F?-o:o;}bool h[2010], s[2010];int n;double f[2010][2010];int m;double dp( int x, int y ){ if( f[x][y] != -1 ) return f[x][y]; if( ! x && ! y ) return f[x][y] = 0; double ans = 0; if( x ) ans += dp( x-1, y ) * x * ( n - y ); if( y ) ans += dp( x, y-1 ) * ( n - x ) * y; if( x && y ) ans += dp( x-1, y-1 ) * x * y; return f[x][y] = (double) ( ans + (double) n * n ) / ( (double) n * ( x + y ) - x * y ) ;}int main(){// freopen("data4.in","r",stdin);// freopen("shoot.out","w",stdout); n = R(); m = R(); int a, b; for( int i = 1; i <= m; i ++ ){ a = R(); b = R(); h[a] = 1; s[b] = 1; } int c = 0, r = 0; for( int i = 1; i <= n; i ++ ){ if( ! h[i] ) c ++; if( ! s[i] ) r ++; } for( int i = 0; i <= n; i ++ ) for( int j = 0; j <= n; j ++ ) f[i][j] = -1; printf("%.2lf",dp(c,r)); return 0;}
阅读全文
0 0
- 打气球(记忆化dp+数学期望)
- 打气球 数学期望
- 聪聪和可可(记忆化dp+数学期望)
- 数学期望DP小结
- LightOJ 1038 Race to 1 Again 期望 记忆化dp
- 【NOI2005T4】聪聪和可可-期望DP+记忆化搜索
- poj 2096(dp数学期望)
- 51nod1670 打怪兽 期望,数学
- hdu-4345-Permutation - DP+数学或记忆化搜索
- zoj 3329(dp-数学期望)
- UVA 5811 Cards 数学期望DP
- uva11176 - Winning Streak 数学期望 DP
- HDU 5396 Expression (数学期望+区间DP)
- [NOIP 2016] 换教室:数学期望,DP
- HDU 5781 数学期望+DP 解题报告
- uva11762 Race to 1 概率dp求期望+记忆化搜索
- [期望dp+记忆化搜索] light oj 1038 Race to 1 Again
- light oj 1038 - Race to 1 Again(概率dp求期望 记忆化搜索)
- cannot define positional parameter after any named parameters have been defined
- MCNN网络解读(一)网络可视化
- Portlet 通信(五) 通过 URL 传递参数
- 两个链表的第一个公共结点
- JSON.parseObject 和 JSON.toJSONString 实例
- 打气球(记忆化dp+数学期望)
- SCRY無域落地日本开启6.5万亿区块链数据市场战略合作
- 新博客 wp.hellocode.name 欢迎访问!此博客不再更新
- 将mysql中数据导入到hbase中出现 NoSuchMethodError
- HDU2023求平均值的问题 2017.10.8
- Java9 基于异步响应式流的发布-订阅框架
- ckplayer播放器
- java基于事件驱动之spring事件驱动
- android studio 图标更换