# 题意与数据范围

$$n$$ 个点不同构的简单无向图的数目，答案对 $$997$$ 取模

$$A$$ 图与 $$B$$ 图被认为是同构的是指：$$A$$ 图的顶点经过一定的重新标号以后，$$A$$ 图的顶点集和边集要完全与 $$B$$ 图一一对应

$$0\le n\le 60$$

# Solution

$\forall (a,b)\in (V,E),\exist (P_a,P_b)\in (V,E)$

$\frac{1}{|G|}\sum\limits_{g\in G}(\prod\limits_{i=1}^{|g|}2^{\lfloor \frac{|g_i|}{2} \rfloor}\prod\limits_{i<j\le |g|}2^{\gcd(|g_i|,|g_j|)})$

$\frac{n!}{\prod\limits_{i=1}^{k}L_i\prod\limits_{i=1}^{n}C_i!}$

$\sum\limits_{\ \ \sum\limits_{i=1}^{k}L_i=n,\\L_1\ge L_2\ge...\ge L_k}\frac{\prod\limits_{i=1}^{k}2^{\lfloor \frac{L_i}{2} \rfloor}\prod\limits_{i<j\le k}2^{\gcd(L_i,L_j)}}{\prod\limits_{i=1}^{k}L_i\prod\limits_{i=1}^{n}C_i!}$

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=1e2+10;
const int mod=997;
int n,L[N],bin[N],fac[N],gcd[N][N],ans,C[N];
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline int MOD(int x){x-=x>=mod? mod:0;return x;}
inline int Minus(int x){x+=x<0? mod:0;return x;}
inline int exgcd(int x,int y){int r;if(y)swap(x,y);while(x&&y)r=x%y,x=y,y=r;return x;}
inline int fas(int x,int p){int res=1;while(p){if(p&1)res=1ll*res*x%mod;p>>=1;x=1ll*x*x%mod;}return res;}
inline void Calc(int m){
int sum=1;
for(register int i=1;i<=m;i++)sum=1ll*sum*bin[L[i]>>1]%mod;
for(register int i=1;i<=m;i++)
for(register int j=i+1;j<=m;j++)
if(i!=j)sum=1ll*sum*bin[gcd[L[i]][L[j]]]%mod;
int fm=1;
for(register int i=1;i<=m;i++)fm=1ll*fm*L[i]%mod;
memset(C,0,sizeof(C));
for(register int i=1;i<=m;i++)C[L[i]]++;
for(register int i=1;i<=n;i++)fm=1ll*fm*fac[C[i]]%mod;
}
inline void DFS(int rest,int las,int num){
if(!rest){Calc(num-1);return;}
for(register int i=1;i<=min(rest,las);i++)
L[num]=i,DFS(rest-i,i,num+1);
}
inline void Preprocess(){
for(register int i=1;i<=n;i++)
for(register int j=1;j<=n;j++)
gcd[i][j]=exgcd(i,j);
fac[0]=1;for(register int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
bin[0]=1;for(register int i=1;i<=n;i++)bin[i]=2ll*bin[i-1]%mod;
}
int main(){
scanf("%d",&n);if(!n){puts("1");return 0;}
Preprocess();DFS(n,n,1);printf("%d\n",ans);
return 0;
}

Luogu P4128 [SHOI2006]有色图

(0)
(0)