摘要: 一道区间 DP cpp include using namespace std; const int N=51; int n,c; int w[N],a[N]; int f[N][N][2],s[N]; //f[i,j,0/1] 关 [i,j] 的灯,现在在左 / 右端点的位置 //s 表示功率的前 阅读全文
posted @ 2019-09-20 17:27 Sshwy 阅读(86) 评论(0) 推荐(0) 编辑
摘要: SDOI2011古代朱文 cpp include/ {{{ / include include include include include include include include include include include include using namespace std; t 阅读全文
posted @ 2019-07-19 15:31 Sshwy 阅读(107) 评论(0) 推荐(0) 编辑
摘要: LIS 问题描述 给出一个数列,找出其中最长的单调递减(或递增)子序列。 例如,A{10,22,9,33,21,50,41,60,80} LIS 的长度是 6,LIS 为 {10,22,33,50,60,80}。 <! more 分析 定义 f[i] 表示以 A[i] 结尾的 LIS 的长度,动态转 阅读全文
posted @ 2019-07-06 20:41 Sshwy 阅读(217) 评论(0) 推荐(0) 编辑
摘要: ZR 2019广州 游记 游记就直接挂在博客园吧 Day0 广州是真的热。 晚上八点才到,讲了一会儿就回寝了。寝室很好啊。 空调开16度。很好。我没感冒。遥控器?咱也不知道,咱也不敢问。 阅读全文
posted @ 2019-07-02 08:01 Sshwy 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 莫队算法模板题 cpp include include include include include include include include include include include using namespace std; typedef long long lld; typede 阅读全文
posted @ 2019-06-28 13:39 Sshwy 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 题意 有 $n$ 个二元组 $(a_i,b_i),1\leq a_i\leq k$,将他们按 $b$ 的升序排列,求区间 $[l,r]$ 满足: $1\leq l\leq r\leq n$. $\bigcup_{i=l}^ra_i=\{1,2,\cdots,k\}$. 要求最小化 $b_r b_l$ 阅读全文
posted @ 2019-06-21 06:52 Sshwy 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 求$1\sim n!$中与$m!$互质的数的个数。$m\leq n\leq 10^7$. 显然$m!|n!$。根据GCD的性质,$(a,b)=(a+b,b)$,则$(a,m!)=(a+m!,m!)$。于是每$m!$分一组,易得 $$ ans=\sum_{i=1}^{n!}[(i,m!)=1]\\ = 阅读全文
posted @ 2019-06-18 19:25 Sshwy 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 题意:一个序列A,支持单点修改,查询位于$x\bmod p=y$的所有A[x]的和。 算见注 cpp include include using namespace std; const int N=150004; int n,m; int a[N]; int tab[1000][1000]; in 阅读全文
posted @ 2019-06-18 17:36 Sshwy 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 队长 · 韩天新 队员 ·GavinZheng&sshwy C 班 RK1.<! more "题面" B. by sshwy C. by GavinZheng cpp include include using namespace std; int main(){ int ans=1 a b c; 阅读全文
posted @ 2019-06-16 18:39 Sshwy 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 2018.8.14 ![Siyuan 小姐姐系列.png][1] 讲题解以前,先膜拜一下 Siyuan 小姐姐家族的人 题面 [0814.pdf][2] A. 数学水题 by sshwy & xry C. 矩阵加速(加分块?) by sry I. 逆序对 by sshwy [1]: https:// 阅读全文
posted @ 2019-06-16 18:36 Sshwy 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题意 在网络流 24 题中隐藏的环形均分纸牌问题 <! more 分析 考虑普通均分纸牌问题 第 $i$ 个人有 $a_i$ 张牌,总牌数为 $sum=\sum_{i=1}^na_i$,均分下来的牌数为 $T=\frac{sum}{n}$. 于是每个人与平均值的差为 $d_i= T a_i$. 如果 阅读全文
posted @ 2019-06-16 07:55 Sshwy 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 分析 考虑 $n$ 的二进制数下的 $1$ 的个数为 $bitcount(n)$ . 则 $n$ 最少可以合并为 $bitcount(n)$ 杯水. 如果 $bitcount(n) k$ ,则让 $n$ 的最右端的 $1$ 向左进位(有可能与左边的 $1$ 合并,也可能只是单纯地把 1 的位置向左移 阅读全文
posted @ 2019-06-15 08:27 Sshwy 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 关键在于读题 知道要求的东西后,直接建立数据结构直接暴力即可 时间复杂度 $O(n^3)$ <! more cpp include using namespace std; const int N=302; int n,s; vector e[N],p[N];//next path int pre[ 阅读全文
posted @ 2019-06-15 08:26 Sshwy 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 分析 汉诺四塔 设 $f[i]$ 表示求解 $i$ 盘四塔的最少步数,设 $d[i]$ 表示求解 $i$ 盘三塔的最少步数: $$ d[i]=2\cdot d[i 1]+1\\ f[i]=\min_{j=1}^{i 1}\left\{2\cdot f[j]+d[i j]\right\} $$ 第二个 阅读全文
posted @ 2019-06-15 08:24 Sshwy 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 分析 对于一条信息 $x,y$,将两者之间的牛的高度 $ 1$. 考虑差分,将区间修改转化为单点修改 注意,排除重复信息 cpp include include include using namespace std; const int N=10004; int n,r,h;//I 省略 int 阅读全文
posted @ 2019-06-15 08:23 Sshwy 阅读(110) 评论(0) 推荐(0) 编辑