[atAGC106F]Figures
考虑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的更多相关文章
- LaTeX插入图表方法 Lists of tables and figures
Lists of tables and figures A list of the tables and figures keep the information organized and prov ...
- 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 ...
- LaTeX:Figures, Tables, and Equations 插入图表和公式
Figures To insert a figure in a LaTeX document, you write lines like this: \begin{figure} \centering ...
- 图片 响应式图像 Images Figures
响应式图像 Bootstrap中的图像响应 .img-fluid <img class="img-fluid" src="http://lorempixel.com ...
- Figures Inscribed in Curves (曲线上的图形)
Figures Inscribed in Curves\text{Figures Inscribed in Curves}Figures Inscribed in Curves A short tou ...
- Inscribed Figures(思维)
The math faculty of Berland State University has suffered the sudden drop in the math skills of enro ...
- Adding supplementary tables and figures in LaTeX【转】
\renewcommand{\thetable}{S\arabic{table}} \renewcommand{\thefigure}{S\arabic{figure}} 这样就以Table S1, ...
- 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\) 的任一位置 ...
- [cf1270I]Xor on Figures
考虑一个构造:令初始$2^{k}\times 2^{k}$的矩阵为$A$(下标从0开始),再构造一个矩阵$T$,满足仅有$T_{x_{i},y_{i}}=1$(其余位置都为0),定义矩阵卷积$\oti ...
随机推荐
- 题解 CF762D Maximum path
题目传送门 Description 给出一个 \(3\times n\) 的带权矩阵,选出一个 \((1,1)\to (3,n)\) 的路径使得路径上点权之和最大. \(n\le 10^5\) Sol ...
- L1-017 到底有多二 (15 分) java解题
1 import java.util.Scanner; 2 3 public class Main { 4 public static void main(String args[]){ 5 doub ...
- websocket方案调研及实践
目录 webscoket方案调研及实践 一.使用场景 二.方案调研 1.Ajax短轮询 2.long-polling长轮询 3.iframe长连接 4.XHR-streaming 5.Websocke ...
- 81. 搜索旋转排序数组 II
题目 已知存在一个按非降序排列的整数数组 nums ,数组中的值不必互不相同. 在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k < nums.length)上进行了 旋 ...
- [no code][scrum meeting] Beta 9
$( "#cnblogs_post_body" ).catalog() 例会时间:5月23日15:30,主持者:肖思炀 下次例会时间:5月25日11:30,主持者:伦泽标 一.工作 ...
- spring cloud ribbon的使用
上节我们学会了如何搭建一个eureka server服务,本节我们使用ribbon来实现服务间的调用. 前置条件: 1.创建几个工程 eureka-server |- 服务注册 ...
- Noip模拟49 2021.9.7
T1 reverse 又一道板子打假的挂分题,直接挂到倒二.. 考场上思路神奇,居然想到用$bfs$建边然后跑最短路, 其实当时也想到了直接$bfs$,但是不知道为啥觉得$dij$屌就没直接打$bfs ...
- 局域网(以太网与IEEE 802.3、IEEE 802.11、)
文章转自:https://blog.csdn.net/weixin_43914604/article/details/105016637 学习课程:<2019王道考研计算机网络> 学习目的 ...
- u-boot 1.1.6 start.S 代码学习<转>
---转自 http://blog.csdn.net/rockhard/article/details/4166642 ------ /* 参考了别人的一些笔记,看完了启动代码. 本文档记录在看代码时 ...
- 第35篇-方法调用指令之invokespecial与invokestatic
这一篇将详细介绍invokespecial和invokestatic字节码指令的汇编实现逻辑 1.invokespecial指令 invokespecial指令的模板定义如下: def(Bytecod ...