poj 1286 polya定理

Necklace of Beads

Description

Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the axis of symmetry are all neglected, how many different forms of the necklace are there?

Input

The input has several lines, and each line contains the input data n.
-1 denotes the end of the input file.

Output

The output should contain the output data: Number of different forms, in each line correspondent to the input data.

Sample Input

4
5
-1

Sample Output

21
39

Solution

polya定理模板题

\(\overline{G}\)是n个对象的一个置换群, 用m种颜色染图这n个对象,则不同的染色方案数为:
\[L=\frac{1}{|\overline{G}|}[m^{c(\overline{p_1}})+m^{c(\overline{p_2}})+...+m^{c(\overline{p_g}})]\]
其中 \(\overline{G}=\{\overline{p_1},\overline{p_2},...,\overline{p_g}\}\)\(c(\overline{p_k})\)\(\overline{p_k}\) 的循环节数(阶)

猜你喜欢

转载自www.cnblogs.com/mooleetzi/p/11355215.html