期望
DP
VL——MOESR
ga
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【CLYZ集训】千与千寻【期望DP】【高斯消元】
题解原创 2023-01-31 12:02:52 · 218 阅读 · 0 评论 -
【2022年10月26日A组】年会小游戏【DFS】
dfs原创 2022-10-26 18:33:47 · 590 阅读 · 0 评论 -
【集训DAY15】好名字【hash】
hash原创 2022-07-25 16:08:06 · 107 阅读 · 0 评论 -
【集训DAY4】Forging【期望DP】
线性求逆远+期望DP原创 2022-07-14 20:05:16 · 138 阅读 · 0 评论 -
【51nod_3144】超级购物【期望】
思路: 我们可以先求在n个人中有r个人买东西的概率,然后求出在这r个人中当且要求的人也在里面的概率,然后一除就是答案 至于求概率的过程要用dp实现 codecodecode #include<iostream> #include<cstring> #include<cstdio> using namespace std; int n, r; double f[100][100], p[100]; double solve(int x) { memset(f..原创 2022-05-04 08:31:19 · 401 阅读 · 0 评论 -
【51nod_3145】扔球游戏【期望】
思路: 每个i和i+1都是独立的,所以只用考虑两位就可以了 然后期望直接算 codecodecode #include<iostream> #include<cstdio> using namespace std; int n, m; int gcd(int x, int y) { if(y==0) return x; else return gcd(y, x%y); } int main() { scanf("%d%d", &n, &m); ..原创 2022-05-03 16:25:58 · 1046 阅读 · 0 评论 -
【51nod_1632】B君的连通【期望】
思路: 我们发现它是一个树,也就是说每断一条边,就会获得1个连通块,那么期望就是1/2 然后统计一下就可以了 codecodecode #include<iostream> #include<cstdio> using namespace std; long long mod=1e9+7; long long n; long long qpow(long long x, long long k) { long long sum=1; while(k) { if..原创 2022-05-03 15:51:50 · 354 阅读 · 0 评论 -
【51nod_1639】绑鞋带【期望】
思路: 考虑当前鞋带头不打环的概率,就是不和它为同一条鞋带的个数*2,把所有都乘起来就可以了 codecodecode #include<iostream> #include<cstdio> using namespace std; int n; int main() { scanf("%d", &n); double ans=1; for(int i=0; i<n*2-2; i+=2) ans=ans*(2*n-i-2)*1.0/(2*n-i-1..原创 2022-05-03 15:37:44 · 320 阅读 · 0 评论 -
【YBTOJ】路径长度 &&【Luogu】绿豆蛙的归宿
思路: 容易想到设i到n的期望长度为did_idi,考虑一条j向i的边w,则did_idi对djd_jdj的贡献为di+wki\frac{d_i+w}{k_i}kidi+w。 有了转移方程,只需要拓扑DP就行了( codecodecode #include<iostream> #include<cstdio> #include<queue> using namespace std; int n, m, du[100100], du1[100100];..原创 2022-02-07 19:38:45 · 263 阅读 · 0 评论 -
2021.08.12【NOIP提高B组】模拟 幻象
思路: 直接期望DP,先把到i的期望长度算出,然后dp时去掉一位算答案 codecodecode #include<iostream> #include<cstdio> using namespace std; int n; double a[1010010], f[1010100], k[1010100]; double ans; int main() { scanf("%d", &n); for(int i=1; i<=n; i++) scanf..原创 2021-08-12 16:54:42 · 147 阅读 · 0 评论 -
2021.07.19【NOIP提高B组】模拟 概率充电器
思路: 首先拓扑一遍,然后树上跑两次,一次求向下传,一次求向上传 codecodecode #include<iostream> #include<cstdio> #include<queue> using namespace std; int n, deg[500100], fa[500100]; int head[500100], tot; struct node { int to, next; double w; }b[5001000]; double..原创 2021-07-20 19:24:51 · 106 阅读 · 0 评论
分享