当前位置:网站首页>省选专练之文艺计算姬
省选专练之文艺计算姬
2022-07-19 11:47:00 【LauJiYeoung】
“奋战三星期,造台计算机”。小W响应号召,花了三星期造了台文艺计算姬。
文艺计算姬比普通计算机有更多的艺术细胞。 普通计算机能计算一个带标号完全图的生成树个数,而文艺计算姬能计算一个带标号完全二分图的生成树个数。
更具体地,给定一个一边点数为n,另一边点数为m,共有n*m条边的带标号完全二分图K_{n,m},计算姬能快速算出其生成树个数。
小W不知道计算姬算的对不对,你能帮助他吗?
这实际上是喜闻乐见的**计数类问题
这道题的解决方法是Prufer序列
我们知道在求一棵树的Prufer序列的时候还剩下最后两个点
他们必然是两个划分集合中的
而此时说明有n-1个和m-1个被选了
那么按照Prufer的性质
一个点出现了几次和他的度数有关
那么这个点出现几次可以随便选
为: N M − 1 ∗ M N − 1 N^{M-1}*M^{N-1} NM−1∗MN−1
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
LL mod,n,m;
LL mul(LL A,LL B){
LL ret=0;
while(B){
if(B&1)ret=(ret+A)%mod;
A=(A+A)%mod;
B=B>>1;
}
return ret;
}
LL Quick_Pow(LL x,LL k){
LL ret=1;
while(k){
if(k&1)ret=mul(ret,x)%mod;
x=mul(x,x)%mod;
k=k>>1;
}
return ret;
}
int main(){
cin>>n>>m>>mod;
cout<<mul(Quick_Pow(n,m-1),Quick_Pow(m,n-1));
}
边栏推荐
- 开源SPL强化MangoDB计算
- 面试被问MySQL 如何去重,还有谁不会?
- 2022.7.10-----leetcode.741
- About XML file (VIII) -dom and validation
- 云原生指南:什么是云原生基础架构
- 【历史上的今天】7 月 8 日:PostgreSQL 发布;SUSE 收购 K8s 最大服务商;动视暴雪合并
- 【历史上的今天】7 月 13 日:数据库之父逝世;苹果公司购买 CUPS 代码;IBM 芯片联盟
- CB insights released seven trends in the AI industry: synthetic data and the rise of multimodal AI
- [论文阅读] Unpaired Image-To-Image Translation Using Cycle-Consistent Adversarial Networks
- Cloud Native Core Technology: Service Mesh Implementation - istio
猜你喜欢
DevOps 实践多年,最痛的居然是?
ICLR 2022 | GNNAsKernel: 能提升任意GNN表达能力的通用框架
Skillfully using roaringbitmap to deal with the memory diff problem of massive data
【云原生】Nacos中的事件发布与订阅--观察者模式
MySQL -- enterprise point general MySQL data synchronization solution
8. Introduction to ORM and introduction to Gorm
自定义持久层框架MyORMFrameworkJDBC回顾和问题分析,自定义持久层框架思路分析
MySync——企点通用MySQL数据同步解决方案
Meiker Studio - Huawei 14 day Hongmeng equipment development practical notes 5
Improve the mirror station configuration information - mirror station experience Officer
随机推荐
Interpretation of CBC mode and ECB mode
好书推荐|《产业数字化转型精要:方法与实践》
OneFlow v0.8.0正式发布
Yuntu says digital asset chain: your God of digital asset property protection
股票开户首选,炒股交易开户佣金最低手机上开户安不安全
阿洛的思考后续
Comparison of eolink and JMeter interface tests
股票开户佣金特惠炒股佣金最低的证券公司,手机上开户安不安全
First choice for stock account opening, lowest Commission for stock trading account opening, is it safe to open an account on mobile phone
TypeScript 基础 — interface 接口
【云驻共创】华为云助力加速构建企业数据资产和数据治理生产线
Quelles sont les principales techniques et pratiques de redis pour soutenir les scènes de second kill?
ACL 2022 | Text-to-Table:一种新的信息抽取任务
【历史上的今天】7 月 13 日:数据库之父逝世;苹果公司购买 CUPS 代码;IBM 芯片联盟
在线XML转JSON工具
ACL 2022 | text to table: a new information extraction task
Conway's Law -- organization decides products, and domain drives design
bootloader的原理分析
自定义持久层框架MyORMFramework(一)—JDBC分析和解决思路
什么是蜜罐