One day , Partychen gets several beads , he wants to make these beads a necklace . But not every beads can link to each other, every bead should link to some particular bead(s). Now , Partychen wants to know how many kinds of necklace he can make.
Input
It consists of multi-case .
Every case start with two integers N,M ( 1<=N<=18,M<=N*N )
The followed M lines contains two integers a,b ( 1<=a,b<=N ) which means the ath bead and the bth bead are able to be linked.
Output
An integer , which means the number of kinds that the necklace could be.
Sample Input
Sample Output
2
题目大概:
有n个珠子,接下来会有m行,表示哪两个珠子可以互相连接。问有多少种连接方案。
思路:
状态dp。
可以把所有珠子压缩成一个数。
dp【i】【j】表示到了状态i,第j个珠子的时候,方案数量。
状态转移方程dp[i|tem][k]+=dp[i][j];
代码: