Codeforces 1097G】的更多相关文章

洛谷 Codeforces 这题真是妙的很. 通过看题解,终于知道了\(\sum_n f(n)^k​\)这种东西怎么算. update:经过思考,我对这题有了更深的理解,现将更新内容放在原题解下方. 思路 发现\(\sum_S (f(S))^k\)这东西因为有个\(k\)次方,所以特别难算,考虑拆开: \[ x^k=\sum_{i=0}^k {x \choose i} \times i! \times S(k,i) \] 其中\(S(n,m)\)是第二类斯特林数,即\(n\)个元素放进\(m​\…
Codeforces 题目传送门 & 洛谷题目传送门 首先看到这题我的第一反应是:这题跟这题长得好像,不管三七二十一先把 \(k\) 次方展开成斯特林数的形式,\(f(X)^k=\sum\limits_{i=0}^k\begin{Bmatrix}k\\i\end{Bmatrix}\dbinom{f(X)}{i}\),于是我们只需对所有 \(i\in[0,k]\) 求出 \(\sum\dbinom{f(X)}{i}\) 即可. 然后就不会做了/dk/wq 考虑 \(\dbinom{f(X)}{i}…
根本想不到 CF1097G 题意 给出一棵树,定义f(S)为用最少的边连通点集$ S$的边数 求$ \sum\limits f(S)^k$ $ n \leq 10^5 k \leq 200$ 题解 假设$ k=1$有一个清真的树形$ DP$ 在点集的$ LCA$处统计答案即可 对于$ k>1$根据二项式定理 可以$ O(nk^2)$完成转移 但这是过不去的 考虑 $$ x^k=\sum_{i=0}^k \binom{x}{i}S(k,i)i!$$ 其中$ S(i,j)$表示第二类斯特林数 拆开组…
题目简述:给定$n \leq 10^5$个节点的树$T = (V, E)$,令$X \subseteq V$表示一个非空节点集合,定义$f(X)$为包含$X$的最小子树的边数.求 $$ \sum_{\emptyset \neq X \subseteq V} (f(X))^k, $$ 其中$k \leq 200$. 解:code 问题转化 我们额外定义$f(\emptyset) = 0$,就不需再单独考虑空集. 利用斯特林数的性质,我们有 $$ x^n = \sum_{k=0}^n k! \beg…
基本定义 第一类斯特林数:$1 \dots n$的排列中恰好有$k$个环的个数:或是,$n$元置换可分解为$k$个独立的轮换的个数.记作 $$ \begin{bmatrix} n \\ k \end{bmatrix}. $$ 第二类斯特林数:将$n$个元素分成$k$个非空集合的方案数.记作 $$ \begin{Bmatrix} n \\ k \end{Bmatrix}. $$ 根据定义,我们有 $$ \sum_{k=0}^n \begin{bmatrix} n \\ k \end{bmatrix…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…