随笔分类 -  算法竞赛 / 动态规划

摘要:从子集和问题到and卷积 枚举子集:O(3n) int u=15; for (int s = u; s; s = (s - 1) & u) { b=s ; cout<<b<<endl; } /* 1111 1110 1101 1100 1011 1010 1001 1000 0111 阅读全文 »
posted @ 2024-05-18 15:54 potential-star 阅读(25) 评论(0) 推荐(0) 编辑
摘要:概率dp 首先是正着递推的计算概率的dp问题 https://ac.nowcoder.com/acm/contest/28263/A 纯数学题 对随机的数字大小分类讨论,计算概率的时候利用高中几何概型的线性规划手法进行计算。 double g=0.5; void solve(){ double k, 阅读全文 »
posted @ 2024-05-18 15:51 potential-star 阅读(17) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P5752 https://codeforces.com/contest/598/problem/E cf这个题考虑dp预处理,状态是三维的,转移是分割方案和所分块需要获得的巧克力数量。最后题目多次询问可以o(1)快速查询的 // P 阅读全文 »
posted @ 2024-03-27 23:09 potential-star 阅读(20) 评论(0) 推荐(0) 编辑
摘要:https://www.acwing.com/problem/content/531/ #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 12, M = 1 < 阅读全文 »
posted @ 2024-03-22 02:12 potential-star 阅读(16) 评论(0) 推荐(0) 编辑
摘要:SDUT 校赛题目 Description 给定正整数 n,计算 n 个元素的集合 {1,2,,n},所有非空子集和的乘积取模 998244353 后的结果。 Input 一个正整数 n (1n200),代 阅读全文 »
posted @ 2023-12-14 15:30 potential-star 阅读(74) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P4316 本题暂时只写了用期望dp经典套路,套上期望DP的基本套路,设dp(u)为到达u点的期望长度。 期望dp,也叫概率dp 一般来说,期望dp找到正确的状态后,转移是比较容易想到的。 但一般情况下,状态一定是“可数”的 事实上, 阅读全文 »
posted @ 2023-12-05 00:56 potential-star 阅读(20) 评论(0) 推荐(0) 编辑
摘要:https://www.acwing.com/problem/content/description/4012/ Acwing long double卡常,注意cin读小数。 #include <bits/stdc++.h> using namespace std; #define ll long 阅读全文 »
posted @ 2023-12-04 23:11 potential-star 阅读(12) 评论(0) 推荐(0) 编辑
摘要:无限制最长连续的子序列和 https://www.acwing.com/problem/content/description/1481/ dp[i]=max(dp[i-1]+a[i],a[i]); 最终结果也就是在dp数组线性扫描找出最大值 int pos=max_element(dp+1,dp+ 阅读全文 »
posted @ 2023-11-28 21:28 potential-star 阅读(22) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示