学习背景:
1.头蜜汁晕,但是很清醒
2.一只蝙蝠造就了我们的相遇
3.内嵌HTML好好玩,有空学学HTML的制作,先转下大佬的怎么搞CSND字体的
先给几个好东西:
1.大佬的论文
2.题目:uva10776
3.这个题目的答案/模板
假设构造最后的矩阵为v[n][n],则计算行列式v[n-1][n-1]的值即det(v[n-1][n-1])为答案(具体看大佬证明),下面给出上面那道题目的代码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep0(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define fre freopen("in.txt","r",stdin)
using namespace std;
const ll mod=10007;
const int maxn=60+7,INF=0x3f3f3f3f;
ll A[maxn][maxn],K[maxn][maxn];
ll tree_sum(int n){
ll res=1;
for(int i=1;i<=n;i++){
if(!K[i][i]){
bool b=0;
for(int j=i+1;j<=n;j++)
if(K[j][i]){
b=1;
for(int k=1;k<=n;k++)
swap(K[i][k],K[j][k]);
res=-res;
break;
}
if(!b)return 0;
}
for(int j=i+1;j<=n;j++)
while(K[j][i]){
ll t=K[i][i]/K[j][i];
for(int k=i;k<=n;k++){
K[i][k]-=t*K[j][k];
swap(K[i][k],K[j][k]);
}
res=-res;
}
res*=K[i][i];
}
return res;
}
int main()
{
// fre;
int n,m,k;
while(scanf("%d%d%d",&n,&m,&k)!=EOF){
memset(A,0,sizeof(A));
memset(K,0,sizeof(K));
for(int i=1;i<=m;i++){
int x,y;scanf("%d%d",&x,&y);
A[x][y]=A[y][x]=1;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(i!=j&&!A[i][j])
K[i][i]++,K[i][j]--;
n--;
ll ans=tree_sum(n);
printf("%lld\n",ans);
}
return 0;
}