[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 ...
随机推荐
- 高级爬虫面试题测试题 v1.3
Python Web高级爬虫工程师测试题 (请本文件发送到: SpiderTestQuestion@163.com 并附带简历) 1. 用yield写一个斐波那契数列的生成器函数. 2. 放一段scr ...
- Java课堂测试1第三阶段
package sizeyunsuan;//import java.util.Scanner;//import java.util.Random;import java.util.*; public ...
- MySQL灵魂拷问:36题带你面试通关!
大家好,我是大彬~ 今天给大家分享MySQL常考的面试题,看看你们能答对多少. 本期MySQL面试题的目录如下: 事务的四大特性? 事务隔离级别有哪些? 索引 什么是索引? 索引的优缺点? 索引的作用 ...
- Java(32)File类的介绍
作者:季沐测试笔记 原文地址:https://www.cnblogs.com/testero/p/15228444.html 博客主页:https://www.cnblogs.com/testero ...
- netty系列之:让TLS支持http2
目录 简介 TLS的扩展协议NPN和ALPN SslProvider ApplicationProtocolConfig 构建SslContext ProtocolNegotiationHandler ...
- 虚拟机研究系列-「GC本质底层机制」SafePoint的深入分析和底层原理探究指南
SafePoint前提介绍 在高度优化的现代JVM里,Safepoint有几种不同的用法.GC safepoint是最常见.大家听说得最多的,但还有deoptimization safepoint也很 ...
- TStor-OneCOS ,主打专一海量对象场景
谁能与你厮守终身 生活在21世纪,最常见的事莫过于更新换代了,找一款能长久适用的产品,是很多人都希望拥有的,特别是针对于云服务产品,而对象·混合云存储新增 TStor-OneCOS 就是这样一款可以 ...
- 手把手教你学Dapr - 2. 必须知道的概念
Sidecar 边车 Dapr API提供Http和gRPC两种通讯方式. 运行方式则可以是容器也可以是进程(Windows开发推荐使用Self Hosted,后续会解释). 这样的好处是与运行环境无 ...
- time_formatter攻防世界学习
time_formatter 前言:这题说实话分析量蛮大的,首先是程序内壁比较绕,而且调用了之前许多没有见到的函数---如snprintf_che,以及strsup(好像打错了),getegid(), ...
- 数位dp & 热身训练7
数位dp 数位dp是一种计数用的dp,一般就是要统计一段区间$[L,R]$内,满足一定条件的数的个数,或者各个数位的个数. 数位dp使得暴力枚举变为满足一定状态的记忆化,更加优秀. 数位dp常常会考虑 ...