HDU 6064 RXD and numbers

传送门

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

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

一个题解的传送门

  1 //Achen
  2 #include<algorithm>
  3 #include<iostream>
  4 #include<cstring>
  5 #include<cstdlib>
  6 #include<vector>
  7 #include<cstdio>
  8 #include<queue>
  9 #include<cmath>
 10 #include<set>
 11 #include<map>
 12 #define Formylove return 0
 13 #define For(i,a,b) for(int i=(a);i<=(b);i++)
 14 #define Rep(i,a,b) for(int i=(a);i>=(b);i--)
 15 const int N=505,p=998244353;
 16 typedef long long LL;
 17 typedef double db;
 18 using namespace std;
 19 LL n,d[N][N],fac[8000007],in[N],out[N];
 20 
 21 template<typename T>void read(T &x)  {
 22     char ch=getchar(); x=0; T f=1;
 23     while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
 24     if(ch=='-') f=-1,ch=getchar();
 25     for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
 26 }
 27 
 28 LL a[N][N];
 29 LL gauss(int n) {
 30     For(i,1,n) For(j,1,n) (a[i][j]+=p)%=p;
 31     LL rs=1,f=1;
 32     For(i,1,n) {
 33         For(j,i+1,n) {
 34             LL A=a[i][i],B=a[j][i];
 35             while(B) {
 36                 LL t=A/B; A%=B; swap(A,B);
 37                 For(k,i,n) a[i][k]=(a[i][k]-t*a[j][k]%p+p)%p;
 38                 For(k,i,n) swap(a[i][k],a[j][k]); f=-f;
 39             }
 40         }
 41         rs=rs*a[i][i]%p;
 42     }
 43     if(f==-1) rs=(p-rs)%p;
 44     return rs;
 45 }
 46 
 47 LL ksm(LL a,LL b) {
 48     LL rs=1,bs=a%p;
 49     while(b) {
 50         if(b&1) rs=rs*bs%p;
 51         bs=bs*bs%p;
 52         b>>=1;
 53     }
 54     return rs;
 55 } 
 56 
 57 int main() {
 58 #ifdef ANS
 59     freopen(".in","r",stdin);
 60     freopen(".out","w",stdout);
 61 #endif
 62     fac[0]=1; int cas=0;
 63     For(i,1,1000000) fac[i]=fac[i-1]*i%p;
 64     while(~scanf("%lld",&n)) {
 65         cas++;
 66         For(i,1,n) in[i]=out[i]=0;
 67         For(i,1,n) For(j,1,n) a[i][j]=0;
 68         For(i,1,n) For(j,1,n) {
 69             read(d[i][j]);
 70             a[i][j]-=d[i][j];
 71             a[j][j]+=d[i][j];
 72             (out[i]+=d[i][j])%=p;
 73             (in[j]+=d[i][j])%=p;
 74         }
 75         int fl=0;
 76         For(i,1,n) if(in[i]!=out[i]) {
 77             fl=1; break;
 78         }
 79         if(fl) {
 80             printf("Case #%d: 0\n", cas);
 81             continue;
 82         }
 83         For(i,2,n) For(j,2,n) a[i-1][j-1]=a[i][j];
 84         LL ans=gauss(n-1);
 85         For(i,2,n) 
 86             ans=ans*fac[in[i]-1]%p;
 87         ans=ans*fac[in[1]]%p;
 88         For(i,1,n) For(j,1,n) if(d[i][j]) 
 89             ans=ans*ksm(fac[d[i][j]],p-2)%p;
 90         printf("Case #%d: %lld\n",cas,ans);
 91     }
 92     Formylove;
 93 }
 94 /*
 95 5
 96 0 1 0 0 0
 97 0 0 1 0 4
 98 0 0 0 5 0
 99 1 5 0 0 0
100 0 0 0 1 0
101 */
View Code

 

转载于:https://www.cnblogs.com/Achenchen/p/9499687.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/413497.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue.js框架的生命周期:常用钩子函数

//组件实例化之前执行的函数 beforeCreate:function () { alert("组件实例化之前执行的函数") }, //组件实例化完毕执行的函数 created:function () { alert("组件实例化完毕执行的函数") }, //组件挂载前&#xff0c;页面仍未展示&#xff0c;但虚拟Dom已…

工作334:uni-控制整个label区域可选

<navigator url"../LevineHua-editor/LevineHua-editor" class"single"><u-form-item label"内容" label-width"100%" prop"content" class"label-left"><u-input placeholder"请输入公告内容…

零基础Python知识点回顾(一)

如果你是小白&#xff0c;建议只要安装官网的python-3.7.0-amd64.exe 然后在电脑cmd命令提示符 输入检查是否已经安装pip,一般安装了python都会有的。 >pip (有的话会提示一大串说明&#xff0c;没有的话会提示没有) 假设有了pip&#xff0c;下面来用pip 来安装…

vue.js常用命令

安装webpack&#xff1a; npm install webpack webpack-cli -g 安装vue-cli&#xff1a; npm install -g vue-cli 用 vue-cli 来构建项目&#xff1a; vue1.x——vue init webpack vue-demo vue2.x——vue init webpack-simple vue-demo 安装路由&#xff1a; npm instal…

工作335:uni-增加表单验证

<u-form-item prop"account"><u-input v-model"form.account" placeholder"请输入账号"></u-input></u-form-item><u-form-item prop"password"><u-input class"inp" v-model"form.p…

使用IDEA 创建SpringBoot项目

首先File ->New -> project ->Spring Initializr ->next 如果没有Spring Initializr 选择右下角config ->setting 搜索Springboot 勾选 然后apply ok 第二步&#xff1a; 在项目中写上自己需要的名称 type 选择 maven project ->next 第三步&#xff1a;…

工作335:uni-ele-el-date-picker限制选择时间

<el-form-item :label"index 1 .发布时间"><el-date-picker v-model"task.start_time" :picker-options"pickerOptions" :disabled"viewMode"/></el-form-item>pickerOptions: {disabledDate(time) {return time…

PhantomJS 一个隐形的浏览器

下载地址: http://phantomjs.org/download.html 使用方法: 下载压缩包解压出来找到phantomjs.exe 放到python的根目录下 转载于:https://www.cnblogs.com/kaibindirver/p/9509684.html

Vue介绍-Vue简单应用-Vue基本用法

什么是Vue&#xff1f;1、Vue.js&#xff08;读音 /vjuː/, 类似于 view&#xff09; 是一套构建用户界面的渐进式框架。2、Vue 只关注视图层&#xff0c; 采用自底向上增量开发的设计。3、Vue 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件。Vue可以用来做…

[css] 你们团队中css的class命名采用的是什么方式呢?下划线还是横线还是驼峰?

[css] 你们团队中css的class命名采用的是什么方式呢&#xff1f;下划线还是横线还是驼峰&#xff1f; 形式 .a .a-b不用驼峰和_&#xff0c;因为这两样都需要 shift 辅助输入, 驼峰越多&#xff0c;按下shift 键的次数就越多。个人简介 我是歌谣&#xff0c;欢迎和大家一起交…

[css] 一个项目中有很多无用的css代码,怎么找到并清除这些无用的代码?

[css] 一个项目中有很多无用的css代码&#xff0c;怎么找到并清除这些无用的代码&#xff1f; 1.使用浏览器插件 2.使用PurifyCSS 3.chrome浏览器 F12审查元素的Audits&#xff0c;手动删个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c;…

Mysql:替换某个字段中的部分字符串——replace函数

需求&#xff1a;因同事操作不当&#xff0c;使某个字段出现了不必要的字符串&#xff0c;导致数据无法正常解析&#xff0c;需要将该字符串统一去掉。

线段树、树状数组

A 树状数组:1 #include<iostream>2 #include<cstdio>3 #include<algorithm>4 #include <string.h>5 using namespace std;6 // 1h / 10min7 const int maxn 32001;8 int c[maxn],ans[maxn]; // c[i] : 以i为横坐标的星星左侧和下侧星星的个数&#xf…

[css] 怎么给手持设备添加特殊样式?

[css] 怎么给手持设备添加特殊样式&#xff1f; -webkit-touch-callout:none ---------- 禁止长按弹出菜单个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关前端面试题

{ parser: babylon } is deprecated; we now treat it as { parser: babel }.

npm run dev 错误提示&#xff1a; { parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }. 治标的解决方法&#xff1a; 找到你的工程文件夹里的 YourProName\node_modules\vue-loader\lib\template-compiler\index.js //将以…

[css] 写出在不固定宽高的元素在固定高度的情况下水平垂直居中的方法

[css] 写出在不固定宽高的元素在固定高度的情况下水平垂直居中的方法 flex布局&#xff1b;还有就是可以用定位也可以实现等等&#xff1b; flex&#xff1a;父div&#xff1a;&#xff5b;display&#xff1a;flex&#xff1b; justify-content: center;align-items: center;…

npm WARN build `npm build` called with no arguments. Did you mean to `npm run-script build`

跑npm build结果如下&#xff1a; npm WARN build npm build called with no arguments. Did you mean to npm run-script build 把指令改成 npm run build 即可

Android内容提供器——运行权限

程序运行是的权限分为两种&#xff0c;一种是普通权限&#xff0c;一种是危险权限。普通权限的话可以直接使用&#xff0c;只有危险权限需要询问用户的同意。 危险权限分组以及组内权限如下&#xff1a; 注&#xff1a;危险权限同一组内有一项权限被授权&#xff0c;则一组权限…

[css] CSS content属性特殊字符有哪些?

[css] CSS content属性特殊字符有哪些&#xff1f; 今天在做开发的时候&#xff0c;需要用到CSS的content属性&#xff0c;加入一些特殊字符来实现网页效果。但是特殊字符那么多&#xff0c;怎么可能记得住&#xff0c;所以谷歌百度搜索之后找到了一个比较全的&#xff0c;在这…

json-server的使用

这里跳过node安装以及npm安装 先全局安装&#xff1a;npm install json-server -g在桌面创建一个空的文件夹JSONSERVERcd 进入到这个文件夹执行npm init --yes&#xff0c;这时候文件夹会多出一个package.json的文件项目再安装一次&#xff1a;npm install json-server --sav…