$$ \newcommand{\seq}[2]{{#1}_{1},{#1}_{2},\cdots,{#1}_{#2}} \newcommand{\num}[1]{1,2,\cdots,#1} \newcommand{\stra}[2]{\begin{bmatrix}#1 \\ #2\end{bmatrix}} \newcommand{\strb}[2]{\begin{Bmatrix}#1 \\ #2\end{Bmatrix}} \newcommand{\dw}[1]{\underline{#1}} \newcommand{\up}[1]{\overline{#1}} $$

05 2019 档案

摘要:考虑以下问题: 给你一棵树,有边权,一条路径合法当它的边权和 $=k$ ,求合法的路径有多少条。 $(n,k\le 2 10^5,\text{Time Limit=3s})$ 暴力 $O(n^2)$ ,即对于每一个点dfs它的子树,把边权装桶。 考虑如何优化。 假设树是随机生成的。那么我们的暴力还是 阅读全文
posted @ 2019-05-21 20:16 chc_1234567890 阅读(130) 评论(0) 推荐(0)
摘要:详细教程 https://www.cnblogs.com/orzzz/p/7885971.html 以下面的一道例题为例。 A.HDU 3507 给出 $N$ 个单词,每个单词有个非负权值 $C_i$ ,现要将它们分成连续的若干段,每段的代价为此段单词的权值和,还要加一个常数 $M$ ,即 $(\s 阅读全文
posted @ 2019-05-18 14:28 chc_1234567890 阅读(118) 评论(0) 推荐(0)
摘要:的 阅读全文
posted @ 2019-05-18 14:28 chc_1234567890 阅读(92) 评论(0) 推荐(0)
摘要:的 阅读全文
posted @ 2019-05-18 14:25 chc_1234567890 阅读(79) 评论(0) 推荐(0)
摘要:容斥原理 $|A_1\cup A_2\cup...\cup A_n|=\sum\limits_{1\le i\le n}|A_i| \sum\limits_{1\le i<j\le n}|A_i\cap A_j|+...+( 1)^{n 1}\times |A_1\cap A_2\cap ...\c 阅读全文
posted @ 2019-05-18 14:24 chc_1234567890 阅读(153) 评论(0) 推荐(0)
摘要:A.HDU 4825 你需要写一种数据结构: 往其中加入一个正整数; 找出一个正整数,使得该数与询问数的异或结果最大。 $n\le 10^5$ 。 解 将数按二进制从高位到低位插入字典树。 查询时从高位往低位贪心。 Code cpp include using namespace std; cons 阅读全文
posted @ 2019-05-18 14:23 chc_1234567890 阅读(153) 评论(0) 推荐(0)
摘要:$T$ 为测试数据组数,时限默认 $1s$ A. $T\le 10000,n\le 10^8$ ,求 $\text{lcm}(1,2,\dots,n)\% 2^{32}$ , $3s$ 首先 $O(n)$ 线性筛,处理出质数的前缀积,时间吃得消,但空间吃不消,所以把线性筛中那个 数组改成 然后 $O 阅读全文
posted @ 2019-05-18 14:22 chc_1234567890 阅读(546) 评论(0) 推荐(0)
摘要:的 阅读全文
posted @ 2019-05-18 14:21 chc_1234567890 阅读(132) 评论(0) 推荐(0)
摘要:两个问题 1 有两个球,现在有人告诉你第一个球是黑色的,问两个球都是黑色的概率。 解 |第一个球|第二个球|概率| |: :|: :|: :| |黑|黑|$\frac{1}{4}$| |黑|白|$\frac{1}{4}$| |白|黑|$\frac{1}{4}$| |白|白|$0$| $\frac{\ 阅读全文
posted @ 2019-05-18 14:20 chc_1234567890 阅读(165) 评论(0) 推荐(0)
摘要:的 阅读全文
posted @ 2019-05-18 14:20 chc_1234567890 阅读(111) 评论(0) 推荐(0)
摘要:的 阅读全文
posted @ 2019-05-18 14:19 chc_1234567890 阅读(153) 评论(0) 推荐(0)
摘要:A. Codeforces 296D 重题 Code 阅读全文
posted @ 2019-05-10 15:47 chc_1234567890 阅读(168) 评论(0) 推荐(0)
摘要:1150 C 题意 给你一个由 $1,2$ 组成的数组,要你重新排列这个数组,使得它的所有是质数的前缀和最长。 $(1\le n\le 200000)$ Examples input 5 1 2 1 2 1 output 1 1 1 2 2 input 9 1 1 2 1 1 1 2 1 1 out 阅读全文
posted @ 2019-05-04 08:38 chc_1234567890 阅读(305) 评论(0) 推荐(0)
摘要:1155 D 题意 给你 $n,x$ 和一个数组 $a$ ,现在你可以把 $a$ 的至多一个子区间的所有元素乘上 $x$ ,问 $a$ 数组最终的美丽值。一个数组的美丽值为 $\max(0,该数组的最大子段和)$ 。 $(n\le 10^5,所有数\le 10^9)$ Examples input 阅读全文
posted @ 2019-05-03 19:43 chc_1234567890 阅读(278) 评论(0) 推荐(0)