当前位置:网站首页>Literary and artistic calculation Ji of provincial election and professional training
Literary and artistic calculation Ji of provincial election and professional training
2022-07-20 14:57:00 【LauJiYeoung】
“ Fighting for three weeks , Build a computer ”. Small W Answer the call , It took three weeks to build a TV station .
Literary computing has more artistic cells than ordinary computers . An ordinary computer can calculate the number of spanning trees of a labeled complete graph , And literary computing can calculate the number of spanning trees of a labeled complete bipartite graph .
More specifically , The number of points on a given side is n, The points on the other side are m, share n*m Labeled complete bipartite graph with edges K_{n,m}, Calculation can quickly calculate the number of spanning trees .
Small W I don't know if Ji's calculation is right , Can you help him ?
This is actually a favorite ** Counting problems
The solution to this problem is Prufer Sequence
We know that we are looking for a tree Prufer The last two points are left in the sequence
They must be in two partitioned sets
At this time, it means n-1 And m-1 Of them were selected
Then according to the Prufer The nature of
How many times a point appears is related to his degree
Then you can choose any number of times this point appears
by : 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));
}
边栏推荐
- 省选专练之 [HAOI2009]毛毛虫
- 【历史上的今天】7 月 17 日:软银收购 ARM;第一次电子邮件中断;维基媒体国际会议
- Rongxu [Linglong Cup] salted fish value
- 【BZOJ2393】Cirno的完美算数教室
- Use masonry to realize width adaptation and height adaptation of controls (including uitableview) according to content
- 浅析IM即时通讯开发中Bitmap到底占用多大内存?
- 读写分离备机备份报错
- 省选专练之【PKUSC2018】主斗地
- 容斥【BZOJ3622】已经没有什么好害怕的了
- 三招从 20s 优化到 500ms
猜你喜欢
云图说丨数字资产链:您的数字资产产权保护神
CBC 模式和 ECB 模式解读
test
【历史上的今天】7 月 15 日:Mozilla 基金会正式成立;Enigma 密码机的首次工作;任天堂推出 FC 游戏机
Go语言 Go语言内置容器
在线XML转JSON工具
QR code intelligent inspection system makes the inspection of power station equipment more intelligent
Was expecting double quote to start field name error
组合数学学习笔记(未完待续
ICLR 2022 | GNNAsKernel: 能提升任意GNN表达能力的通用框架
随机推荐
PL-VIO: Tightly-Coupled Monocular Visual–Inertial Odometry Using Point and Line Features
UICollectionViewCell和UITableViewCell上下左右留空白
JSD-2204-微博项目(完结)-Day16
自定义持久层框架MyORMFrameworkJDBC回顾和问题分析,自定义持久层框架思路分析
剑指offer题库总结(三)之链表(C语言版本)
Conway's Law -- organization decides products, and domain drives design
Link: fatal error lnk1104: unable to open the file "ucrtd.lib" workaround Visual Studio
Devops has been practiced for many years. What is the most painful thing?
Interpretation of CBC mode and ECB mode
不等式学习笔记
Was expecting double quote to start field name error
DevOps 实践多年,最痛的居然是?
[bzoj2393] cirno's perfect math classroom
Recommend a development tool that supports data + code generation! yyds
Build a full stack web application framework in 1 hour, support secondary development, and update and expand at any time
Redis支撐秒殺場景的關鍵技術和實踐都有哪些?
省选专练之GCD生成树
freeotp 安装及使用过程[通俗易懂]
Week 5 Image Classification、Bag of Visual Words (Bag of Features) and Multi-Layer Neural Networks
Import word document pictures kernel synchronization and mutual exclusion