考虑purfer序列,若生成树的pufer序列为$p_{i}$,则答案为$(\prod_{i=1}^{n}a_{i})\sum_{p}\prod_{i=1}^{n}\frac{(a_{i}-1)!}{(a_{i}-1-s_{i})!}$(其中$s_{i}$为$p$中点$i$出现的次数,即度数减1)

(以下令$a_{i}$减1)观察到式子只与$s_{i}$有关,对于相同的$s_{i}$对应$p_{i}$有$\frac{(n-2)!}{\prod_{i=1}^{n}s_{i}!}$种,令$C=(n-2)!\prod_{i=1}^{n}a_{i}$,代入即$ans=C\sum_{\sum_{i=1}^{n}s_{i}=n-2}\prod_{i=1}^{n}\frac{a_{i}!}{s_{i}!(a_{i}-s_{i})!}$

令$f(x)=\sum_{k=0}^{n-2}(\sum_{\sum_{i=1}^{n}s_{i}=k}\frac{a_{i}!}{s_{i}!(a_{i}-s_{i})!})x^{k}=\sum_{s_{i}}\prod_{i=1}^{n}\frac{a_{i}!}{s_{i}!(a_{i}-s_{i})!}\cdot x^{s_{i}}$,答案即$f(x)[x^{n-2}]$

不妨先枚举$s_{1},s_{2},..$,再提取出对应位置上的式子作为公因式,之后由于各位上完全独立,再将结果乘起来就是原式,即$f(x)=\prod_{i=1}^{n}\sum_{s_{i}=0}^{a_{i}}\frac{a_{i}!}{s_{i}!(a_{i}-s_{i})!}\cdot x^{s_{i}}=(1+x)^{\sum_{i=1}^{n}a_{i}}$

因此$f(x)[x^{n-2}]=c(\sum_{i=1}^{n}a_{i},n-2)$(注意这里的$a_{i}$减了1),发现$(n-2)!$已经被抵消掉,因此直接枚举$\sum_{i=1}^{n}a_{i}$到$\sum_{i=1}^{n}a_{i}-(n-2)+1$即可

 1 #include<bits/stdc++.h>
2 using namespace std;
3 #define mod 998244353
4 int n,x,s,ans;
5 int main(){
6 scanf("%d",&n);
7 ans=1;
8 for(int i=1;i<=n;i++){
9 scanf("%d",&x);
10 ans=1LL*ans*x%mod;
11 s=(s+x-1)%mod;
12 }
13 for(int i=0;i<n-2;i++)ans=1LL*ans*(s-i+mod)%mod;
14 printf("%d",ans);
15 }

[atAGC106F]Figures的更多相关文章

  1. LaTeX插入图表方法 Lists of tables and figures

    Lists of tables and figures A list of the tables and figures keep the information organized and prov ...

  2. Deployed component GUIs and figures have different look and feel than MATLAB desktop

    原文:http://www.mathworks.com/support/bugreports/1293244 Description Deployed GUIs and figures look an ...

  3. LaTeX:Figures, Tables, and Equations 插入图表和公式

    Figures To insert a figure in a LaTeX document, you write lines like this: \begin{figure} \centering ...

  4. 图片 响应式图像 Images Figures

    响应式图像 Bootstrap中的图像响应 .img-fluid <img class="img-fluid" src="http://lorempixel.com ...

  5. Figures Inscribed in Curves (曲线上的图形)

    Figures Inscribed in Curves\text{Figures Inscribed in Curves}Figures Inscribed in Curves A short tou ...

  6. Inscribed Figures(思维)

    The math faculty of Berland State University has suffered the sudden drop in the math skills of enro ...

  7. Adding supplementary tables and figures in LaTeX【转】

    \renewcommand{\thetable}{S\arabic{table}} \renewcommand{\thefigure}{S\arabic{figure}} 这样就以Table S1, ...

  8. Wannafly Winter Camp 2020 Day 5J Xor on Figures - 线性基,bitset

    有一个\(2^k\cdot 2^k\) 的全零矩阵 \(M\),给出 \(2^k\cdot 2^k\) 的 \(01\) 矩阵 \(F\),现在可以将 \(F\) 的左上角置于 \(M\) 的任一位置 ...

  9. [cf1270I]Xor on Figures

    考虑一个构造:令初始$2^{k}\times 2^{k}$的矩阵为$A$(下标从0开始),再构造一个矩阵$T$,满足仅有$T_{x_{i},y_{i}}=1$(其余位置都为0),定义矩阵卷积$\oti ...

随机推荐

  1. WebXml文件与SpringMVC的联系

    WebXml文件与SpringMVC的联系 无论采用何种框架来进行Java Web的开发,只要是Web项目必须在WEB-INF下有web.xml,这是java规范. 当然,我们最早接触到Java We ...

  2. C++优化列表

    #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC ...

  3. pycharm上的python虚拟环境移到离线机器上

    Pycharm的Terminal 中执行: 查看现有的包到requirements.txt中 pip freeze > requirements.txt 生成依赖包 D:\machangwei\ ...

  4. yum源安装nginx

    nginx使用yum源安装 安装步骤 使用yum源安装依赖 yum install yum-utils 配置nginx.repo的yum文件 vim /etc/yum.repos.d/nginx.re ...

  5. 一文弄懂CGAffineTransform和CTM

    一文弄懂CGAffineTransform和CTM 一些概念 坐标空间(系):视图(View)坐标空间与绘制(draw)坐标空间 CTM:全称current transformation matrix ...

  6. 更好的 java 重试框架 sisyphus 背后的故事

    sisyphus 综合了 spring-retry 和 gauva-retrying 的优势,使用起来也非常灵活. 今天,让我们一起看一下西西弗斯背后的故事. 情景导入 简单的需求 产品经理:实现一个 ...

  7. Hash窃取与传递

    Hash窃取与传递 NTHASH(NTLM) 在 Windows中, 存储的密码Hash就叫做 NTHash,也叫做 NTLM,其中NTLM 全称是 "NT LAN Manager" ...

  8. change or reset WSL password

    change or reset WSL password To change or reset your password, open the Linux distribution and enter ...

  9. javascript-jquery的基本方法

    1.去除字符串中两端的空格$.trim(str) var str1=" 123 " $.trim(str1);//123 2.遍历对象的数据并进行操作$.each(obj,func ...

  10. 谜语人队 Scrum Meeting 博客汇总

    项目 内容 课程主页 2021春季软件工程(罗杰 任健) 作业要求地址 Alpha阶段:团队项目-每日例会报告Beta阶段:团队项目-每日例会报告 团队博客主页 谜语人队 一.Alpha阶段 第一次例 ...