随笔分类 - 容斥
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc041_f "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc041/tasks/agc041_f "AtCoder 传送门") 神题!!!!!!!
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/P6667 "洛谷传送门") 点值不好搞。考虑把它搞成系数一类的东西。 由二项式反演,$f(x) = \sum\limits_{i = 0}^x \binom{x}{i} b_i \Leftrightarrow b_i
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc309_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc309/tasks/abc309_g "AtCoder 传送门") 前置知识:[[AR
阅读全文
摘要:[UOJ 传送门](https://uoj.ac/problem/37 "UOJ 传送门") 考虑 dp。设 $f_S$ 为点集 $S$ 构成强连通分量的方案数。 容易想到容斥。设 $ed_S$ 为 $S$ 内部连边数,那么 $f_S$ 就是总的方案数 $2^{ed_S}$ 减去构成的不是强连通分量
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF997C "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/997/C "CF 传送门") 考虑容斥,钦定 $i$ 行 $j$ 列放同一种颜色,
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc058_d "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc058/tasks/agc058_d "AtCoder 传送门") Orz H6_6Q
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc021_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc021/tasks/agc021_e "AtCoder 传送门") 容易发现一个变色龙
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc245_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc245/tasks/abc245_h "AtCoder 传送门") 很好的题。 下文令
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc242_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc242/tasks/abc242_h "AtCoder 传送门") 好久没复习过 mi
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc253_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc253/tasks/abc253_h "AtCoder 传送门") 没做出来。 考虑求
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc214_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc214/tasks/abc214_g "AtCoder 传送门") 比较平凡的一个容斥
阅读全文
摘要:洛谷传送门 AtCoder 传送门 感觉挺高妙的…… 为了方便,不妨把横纵坐标都整体减 $1$。 如果单独考虑上下移动,方案数是 $\binom{2n}{n}$。发现两个人上下总共移动 $n$ 次后一定会在同一行,设这行编号为 $x$,那么最后带个 $\binom{n}{x}^2$ 的系数,并且除掉
阅读全文
摘要:洛谷传送门 AtCoder 传送门 设 $P$ 的原根为 $g$,那么 $x,y$ 可以表示成 $g^a, g^b$ 的形式(特判 $x = y = 0$)。那么要求 $an \equiv b \pmod {P - 1}$,其中 $a,b \in [1, P - 1]$。 考虑固定 $a$,可以把问
阅读全文
摘要:洛谷传送门 AtCoder 传送门 搞笑题,我不会做,我更搞笑。 考虑逆序操作,即初始有一个全 $0$ 序列,每次单点加 $k$ 或者长为 $k$ 区间加 $1$。考虑把一个操作集合唯一对应到一个最终序列,不难发现只要限制每个区间加 $1$ 的次数 $< k$ 即可。因为如果正序操作,加上了限制,每
阅读全文
摘要:洛谷传送门 AtCoder 传送门 提供一种形式化的理解方法。 设 $S$ 为任意一条从 $(0,0)$ 到 $(n+1,n+1)$ 的路径经过的点集,$P$ 为 所有 合法障碍点集,$Q$ 为 题目给定的 障碍点集。显然现在 $S$ 和 $P$ 都不确定,题目即求 $\sum\limits_S \
阅读全文
摘要:洛谷传送门 考虑不要求每个盒子至少放一个球,答案即为 $\sum\limits_{i=0}^A \binom{n}{i} \times \sum\limits_{i=0}^B \binom{n}{i} \times \sum\limits_{i=0}^C \binom{n}{i}$。 加上这个条件,
阅读全文
摘要:洛谷传送门 AtCoder 传送门 不错的组合计数题。 因为黑车和白车不能在同一行或者同一列,所以可以考虑枚举黑车有 $i$ 行 $k$ 列的位置放,白车有 $j$ 行 $l$ 列的位置放。如果设 $f_{i,j,k}$ 为 $i$ 行 $j$ 列的棋盘,需要放 $k$ 个车,且 每一行每一列都必须
阅读全文
摘要:洛谷传送门 AtCoder 传送门 题目可以转化成所有 $\gcd(p_i,p_j) \ne 1$ 的对数减去 $\gcd(i,j) = 1$ 且 $\gcd(p_i,p_j) \ne 1$ 的对数。 可以考虑外面套一层容斥,枚举 $d$,计算下标为 $d$ 的倍数的数中满足 $\gcd(p_i,p
阅读全文

浙公网安备 33010602011771号