传送门:http://www.wikioi.com/problem/2926/
Polya定理,看到高精度就不想写C++……python打了个表……,题解&C++源码有空再发
import pdb for n in range(1,21): v=[[0]*22 for i in range(22)] tmp=[[0]*22 for i in range(22)] Hash=[[0]*22 for i in range(22)] a=[0]*444 vis=[0]*444 tot=1 ans=0 global res res=0 def turn(): for i in range(1,n+1): for j in range(1,n+1): tmp[i][j]=v[i][j] for i in range(1,n+1): for j in range(1,n+1): v[i][j]=tmp[n-j+1][i-j+1] def turnover(): for i in range(1,n+1): for j in range(1,n+1): tmp[i][j]=v[i][j] for i in range(1,n+1): for j in range(1,n+1): v[i][j]=tmp[i][i-j+1] def dfs(x): while vis[x]==0: vis[x]=1 x=a[x] for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 #Case 1 for i in range(1,n+1): for j in range(1,i+1): a[Hash[i][j]]=v[i][j] for i in range(1,tot): if vis[i]==0: res+=1 dfs(i) ans+=2**res res=0 vis=[0]*444 tot=1 for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 #pdb.set_trace() #Case 2 #pdb.set_trace() turn() for i in range(1,n+1): for j in range(1,i+1): a[Hash[i][j]]=v[i][j] for i in range(1,tot): if vis[i]==0: res+=1 dfs(i) ans+=2**res res=0 vis=[0]*444 tot=1 for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 #Case 3 turn() turn() for i in range(1,n+1): for j in range(1,i+1): a[Hash[i][j]]=v[i][j] for i in range(1,tot): if vis[i]==0: res+=1 dfs(i) ans+=2**res res=0 vis=[0]*444 tot=1 for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 #Case 4 turnover() for i in range(1,n+1): for j in range(1,i+1): a[Hash[i][j]]=v[i][j] for i in range(1,tot): if vis[i]==0: res+=1 dfs(i) ans+=2**res res=0 vis=[0]*444 tot=1 for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 #Case 5 turn() turnover() for i in range(1,n+1): for j in range(1,i+1): a[Hash[i][j]]=v[i][j] for i in range(1,tot): if vis[i]==0: res+=1 dfs(i) ans+=2**res res=0 vis=[0]*444 tot=1 for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 #Case 6 turn() turn() turnover() for i in range(1,n+1): for j in range(1,i+1): a[Hash[i][j]]=v[i][j] for i in range(1,tot): if vis[i]==0: res+=1 dfs(i) ans+=2**res res=0 vis=[0]*444 tot=1 for i in range(1,n+1): for j in range(1,i+1): Hash[i][j]=tot v[i][j]=tot tot+=1 print 'f['+str(n)+']="'+str(ans/6)+'";'