考虑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. 国内首篇云厂商 Serverless 论文入选全球顶会:突发流量下,如何加速容器启动?

    作者 | 王骜 来源 | Serverless 公众号 导读 ​ USENIX ATC (USENIX Annual Technical Conference) 学术会议是计算机系统领域的顶级会议,入 ...

  2. 教你 4 步搭建弹性可扩展的 WebAPI

    作者 | 萧起  阿里云云原生团队 本文整理自<Serverless 技术公开课>,关注"Serverless"公众号,回复"入门",即可获取 Se ...

  3. Java(14)面向对象之封装

    作者:季沐测试笔记 原文地址:https://www.cnblogs.com/testero/p/15201610.html 博客主页:https://www.cnblogs.com/testero ...

  4. 【c++ Prime 学习笔记】第1章 开始

    1.1 编写一个简单的程序 int main() { return 0; } 函数 包含4部分: 返回类型(return type) 函数名(function name) 形参列表(parameter ...

  5. Coursera Deep Learning笔记 结构化机器学习项目 (上)

    参考:https://blog.csdn.net/red_stone1/article/details/78519599 1. 正交化(Orthogonalization) 机器学习中有许多参数.超参 ...

  6. [敏捷软工团队博客]Beta阶段使用指南

    软件工程教学实践平台使用指南 项目地址:http://20.185.223.195:8000/ 项目团队:the agiles 进入界面如图: 目录 软件工程教学实践平台使用指南 学生端 登录 iss ...

  7. UltraSoft - DDL Killer - Alpha 项目展示

    团队介绍 CookieLau fmh 王 FUJI LZH DZ Monster PM & 后端 前端 前端 前端 后端 后端 软件介绍 项目简介 项目名称:DDLKiller 项目描述:&q ...

  8. 关于QGIS的插件开发(C++)

    关于C++插件的开发材料较少,根据网上的指导,我采用了早期版本的插件模板生成的方法来创建QGIS的插件,其方法是从以前版本(2.18.25)里面拷贝插件模板的方法进行,具体的执行步骤为 1.拷贝文件 ...

  9. vs2017和Qt5的字符编码问题

    默认vs2017的源文件字符编码是gbk的格式,Qt5的内部字符编码为utf8的格式,Qt5又去掉了设置字符串的接口,这样在源文件中使用了字符串之后,就会出现乱码问题,对原有代码逐个修改字符串是不可能 ...

  10. 零基础入门stm32基本定时器详解

    一.基本定时器介绍 在STM32中,基本定时器有TIM6.TIM7等.基本定时器主要包含时基单元,提供16位的计数,能计数0~65535.基本定时器除了计数功能以外,还能输出给DAC模块一个TRGO信 ...