传送门

有向图生成树计数 (度数 ->入度->外向树)

BEST定理 (不定起点的欧拉回路个数=某点为根的外向树个数(存在欧拉回路->每个点为根的外向树个数相等)*(每个点的度数(存在欧拉回路->每个点入度=出度)-1)的阶层)

一个题解的传送门

 //Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#include<map>
#define Formylove return 0
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int N=,p=;
typedef long long LL;
typedef double db;
using namespace std;
LL n,d[N][N],fac[],in[N],out[N]; template<typename T>void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} LL a[N][N];
LL gauss(int n) {
For(i,,n) For(j,,n) (a[i][j]+=p)%=p;
LL rs=,f=;
For(i,,n) {
For(j,i+,n) {
LL A=a[i][i],B=a[j][i];
while(B) {
LL t=A/B; A%=B; swap(A,B);
For(k,i,n) a[i][k]=(a[i][k]-t*a[j][k]%p+p)%p;
For(k,i,n) swap(a[i][k],a[j][k]); f=-f;
}
}
rs=rs*a[i][i]%p;
}
if(f==-) rs=(p-rs)%p;
return rs;
} LL ksm(LL a,LL b) {
LL rs=,bs=a%p;
while(b) {
if(b&) rs=rs*bs%p;
bs=bs*bs%p;
b>>=;
}
return rs;
} int main() {
#ifdef ANS
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
fac[]=; int cas=;
For(i,,) fac[i]=fac[i-]*i%p;
while(~scanf("%lld",&n)) {
cas++;
For(i,,n) in[i]=out[i]=;
For(i,,n) For(j,,n) a[i][j]=;
For(i,,n) For(j,,n) {
read(d[i][j]);
a[i][j]-=d[i][j];
a[j][j]+=d[i][j];
(out[i]+=d[i][j])%=p;
(in[j]+=d[i][j])%=p;
}
int fl=;
For(i,,n) if(in[i]!=out[i]) {
fl=; break;
}
if(fl) {
printf("Case #%d: 0\n", cas);
continue;
}
For(i,,n) For(j,,n) a[i-][j-]=a[i][j];
LL ans=gauss(n-);
For(i,,n)
ans=ans*fac[in[i]-]%p;
ans=ans*fac[in[]]%p;
For(i,,n) For(j,,n) if(d[i][j])
ans=ans*ksm(fac[d[i][j]],p-)%p;
printf("Case #%d: %lld\n",cas,ans);
}
Formylove;
}
/*
5
0 1 0 0 0
0 0 1 0 4
0 0 0 5 0
1 5 0 0 0
0 0 0 1 0
*/

HDU 6064 RXD and numbers的更多相关文章

  1. 2017 多校3 hdu 6061 RXD and functions

    2017 多校3 hdu 6061 RXD and functions(FFT) 题意: 给一个函数\(f(x)=\sum_{i=0}^{n}c_i \cdot x^{i}\) 求\(g(x) = f ...

  2. HDU 6061 - RXD and functions | 2017 Multi-University Training Contest 3

    每次NTT都忘记初始化,真的是写一个小时,Debug两个小时- - /* HDU 6061 - RXD and functions [ NTT ] | 2017 Multi-University Tr ...

  3. HDU 6060 - RXD and dividing | 2017 Multi-University Training Contest 3

    /* HDU 6060 - RXD and dividing [ 分析,图论 ] | 2017 Multi-University Training Contest 3 题意: 给一个 n 个节点的树, ...

  4. HDU 6063 - RXD and math | 2017 Multi-University Training Contest 3

    比赛时候面向过题队伍数目 打表- - 看了题解发现确实是这么回事,分析能力太差.. /* HDU 6063 - RXD and math [ 数学,规律 ] | 2017 Multi-Universi ...

  5. hdu 6063 RXD and math(快速幂)

    RXD and math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)To ...

  6. hdu 5272 Dylans loves numbers

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5272 Dylans loves numbers Description Who is Dylans?Y ...

  7. hdu 5272 Dylans loves numbers 水题

    Dylans loves numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...

  8. 2017 ACM暑期多校联合训练 - Team 3 1008 HDU 6063 RXD and math (莫比乌斯函数)

    题目链接 Problem Description RXD is a good mathematician. One day he wants to calculate: ∑i=1nkμ2(i)×⌊nk ...

  9. hdu 1058 dp.Humble Numbers

    Humble Numbers Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Subm ...

随机推荐

  1. 页面上有3个输入框:分别为max,min,num;三个按钮:分别为生成,排序,去重;在输入框输入三个数字后,先点击生成按钮,生成一个数组长度为num,值为max到min之间的随机整数点击排序,对当前数组进行排序,点击去重,对当前数组进行去重。 每次点击之后使结果显示在控制台

    <!DOCTYPE html> <html> <head> <!-- 页面上有3个输入框:分别为max,min,num:三个按钮:分别为生成,排序,去重: 在 ...

  2. FTPClient登录慢的问题

    java上传文件到ftp上,发现特别慢,debug了一下发现链接正常,ftp.login(username, password)这个登录方法特别慢 解决方案: vi /etc/vsftpd/vsftp ...

  3. 2019-9-18-WPF-客户端开发需要知道的触摸失效问题

    title author date CreateTime categories WPF 客户端开发需要知道的触摸失效问题 lindexi 2019-09-18 15:30:38 +0800 2019- ...

  4. 关于mysql的权限的问题

    昨天因为同学的mysql数据库不知道做了什么操作,从而导致root用户无法使用了 具体是使用root用户不需要密码 进去只能看 看到 infomation_schema 表 ,感觉root权限丢失了 ...

  5. Oracle 、MySql 数据库表被锁的原因分析

    记录一次准备给客户预演示出现的问题 事故的背景: 当所以功能开发完成后,开发人员在本地进行了测视已经没问题了.就把所有开发的功能模块合并到 dev 分支,进行打包,发布到预演示的线上环境.当在给相关人 ...

  6. 8-26接口压力测试-3Jmeter-Java请求

    1.新建maven工程 2.导入依赖,并使用shade将所需的依赖打入jar包 <?xml version="1.0" encoding="UTF-8"? ...

  7. Python Django主机管理

    1.新建一个django project项目 django-admin startproject DjangoWeb 2.新建app python manage.py startapp master ...

  8. NX二次开发-UFUN拉伸函数UF_MODL_create_extruded2

    NX9+VS2012 //NX二次开发中常用拉伸函数为UF_MODL_create_extruded2,但是此函数不能拉伸片体, //想要拉伸片体用函数UF_MODL_create_extruded. ...

  9. NX二次开发-获得图纸抑制尺寸的表达式UF_DRF_ask_controlling_exp

    #include <uf.h> #include <uf_modl.h> #include <uf_drf.h> #include <uf_obj.h> ...

  10. FZU - 2295 Human life:网络流-最大权闭合子图-二进制优化-第九届福建省大学生程序设计竞赛

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 http://acm.fzu.edu.cn/problem.php?pid=2295 htt ...