标签:矩阵 def i++ line math class pre online include
有向生成树计数。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MAXN 1010
#define mod 10007
using namespace std;
int n,m,ans=1;
int sum[MAXN][MAXN];
int main()
{
#ifndef ONLINE_JUDGE
freopen("ce.in","r",stdin);
#endif
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
int u,v;
scanf("%d%d",&v,&u);
sum[v][v]++;
sum[u][v]--;
}
for(int i=2;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
while(sum[j][i])
{
int t=sum[i][i]/sum[j][i];
for(int k=i;k<=n;k++)
{
sum[i][k]=(sum[i][k]+mod-sum[j][k]*t%mod)%mod;
swap(sum[i][k],sum[j][k]);
}
ans*=-1;
}
}
}
for(int i=2;i<=n;i++) ans=1ll*ans*sum[i][i]%mod;
printf("%d\n",(ans+mod)%mod);
return 0;
}
标签:矩阵 def i++ line math class pre online include
原文地址:https://www.cnblogs.com/fengxunling/p/10909316.html