cf1173 D. Nauuo and Circle
链接
[cf]http://codeforces.com/contest/1175/problem/F)
思路
当1在1的位置做dp[i]为i的子树所有的方案。
一条性质是i的子树所占圆上的位置一定一段连续的。
那\(f[i]\)的方案就是$(son[i]+(i!=1))!\prod\limits_{x \in i }f[x] \(
其实就是\)n*\prod\limits_{i=1}^{n}ru[i]! $
代码
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+7,mod=998244353;
int n,ru[N],jc[N],ans=1;
int main() {
scanf("%d",&n);
for(int i=1,x,y;i<n;++i) {
scanf("%d%d",&x,&y);
ru[x]++,ru[y]++;
}
jc[1]=1;
for(int i=2;i<=n;++i) jc[i]=1LL*jc[i-1]*i%mod;
for(int i=1;i<=n;++i) ans=1LL*ans*(jc[ru[i]])%mod;
cout<<1LL*n*ans%mod<<"\n";
return 0;
}
cf1173 D. Nauuo and Circle的更多相关文章
- Codeforces Round #564 (Div. 2) D. Nauuo and Circle(树形DP)
D. Nauuo and Circle •参考资料 [1]:https://www.cnblogs.com/wyxdrqc/p/10990378.html •题意 给出你一个包含 n 个点的树,这 n ...
- B. Nauuo and Circle 解析(思維、DP)
Codeforce 1172 B. Nauuo and Circle 解析(思維.DP) 今天我們來看看CF1172B 題目連結 題目 略,請直接看原題 前言 第一個該觀察的事情一直想不到,看了解答也 ...
- 【题解】Luogu CF1172B Nauuo and Circle
原题传送门 题意:在圆上有n个节点(珂以构成凸多边形),让你给节点编号,使得将题目给你的边(一棵树)没有交叉 我们钦定1为这个树的根节点.任意节点\(x\)的一颗子树的点应该是圆弧上连续的一段(我也不 ...
- Cf D. Nauuo and Circle
https://codeforces.com/contest/1173/problem/D 题意: 给出你一个包含 n 个点的树,这 n 个点编号为 1~n: 给出一个圆,圆上放置 n 个位置,第 i ...
- Codeforces Round #564 比赛总结
这次是中国大佬出题,结果被虐惨了. A. Nauuo and Votes #include<bits/stdc++.h> #define Rint register int using n ...
- Codeforces Round #564 (Div. 1)
Codeforces Round #564 (Div. 1) A Nauuo and Cards 首先如果牌库中最后的牌是\(1,2,\cdots, k\),那么就模拟一下能不能每次打出第\(k+i\ ...
- [翻译svg教程]svg中的circle元素
svg中的<circle> 元素,是用来绘制圆形的,例如 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= ...
- 设计一个程序,程序中有三个类,Triangle,Lader,Circle。
//此程序写出三个类,triangle,lader,circle:其中triangle类具有类型为double的a,b,c边以及周长,面积属性, //具有周长,面积以及修改三边的功能,还有判断能否构成 ...
- c++作业:Circle
Circle Github链接
随机推荐
- SQL Server 新增自动执行任务
第一步右击SQL Server代理,新建作业 第二步选择常规,给你要执行的计划命名 第三步选择步骤,然后给步骤命名,选择类型,数据库,输入你要执行的语句. 第四步设置要执行的频率,根据业务需要,一般建 ...
- SQL server中常用sql语句
--循环执行插入10000条数据 declare @ID intbeginset @ID=1 while @ID<=10000begininsert into table_name values ...
- Windows 搭建 nginx rtmp服务器
1.环境开发环境:windows开发工具:ffmpeg.nginx.nginx-rmtp-module.vlc media player播放器 2.准备文件官方ffmpeg下载地址:http://ww ...
- 记一次Spring boot集成mybatis错误修复过程 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
最近自己写了一份代码签入到github,然后拉下来运行报下面的错误 Error starting ApplicationContext. To display the conditions repor ...
- 【转载】C#通过InsertAt方法在DataTable特定位置插入一条数据
在C#中的Datatable数据变量的操作过程中,可以通过DataTable变量的Rows属性的InsertAt方法往DataTable的指定位置行数位置插入一个新行数据,即往DataTable表格指 ...
- Executor的线程代码
package com.open1111; import java.util.concurrent.ExecutorService;import java.util.concurrent.Execut ...
- caffe库源码剖析——net层
net层的功能实现主要涉及到net.hpp和net.cpp文件,让我们要捋顺它是干了什么,是如何实现的. 1. net层使用到的参数 第一步要做的事,就是查看caffe.proto文件,弄清楚net都 ...
- MySQL登录时出现 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES) 的原因及解决办法
场景一:调试web程序访问数据库的时候出现 场景二:MySQL登陆的时候,区分本地localhost登陆,以及远程登陆.即使本地能够登陆,如果不授权也无法远程登陆 分析原因:(区分)当本地出现这样的情 ...
- MobX入门示例
在相当长的一段时间内,Redux 都是前端开发人员作为状态管理的首先框架,如果不会 Redux,你都不好意思跟别人说自己是搞前端的. 没过多久,开发者们开始意识到,这东西虽说盛行,但它并没有传说中的那 ...
- python中生成JWK(json web token)
#需要安装pyjwt import jwt import time # 使用 sanic 作为restful api 框架 def create_token(request): grant_type ...