HOJ The Colored Cubes

The Colored Cubes

My Tags   (Edit)
  Source : UVA
  Time limit : 1 sec   Memory limit : 32 M

Submitted : 167, Accepted : 77

All 6 sides of a cube are to be coated with paint. Each side is is coated uniformly with one color. When a selection of n different colors of paint is available, how many different cubes can you make?

Note that any two cubes are only to be called "different" if it is not possible to rotate the one into such a position that it appears with the same coloring as the other.

Input

Each line of the input file contains a single integer n(0 < n < 1000) denoting the number of different colors. Input is terminated by a line where the value of n=0. This line should not be processed.

Output

For each line of input produce one line of output. This line should contain the number of different cubes that can be made by using the according number of colors.

Sample Input

1
2
0

Sample Output

1
10

问题大意:对于一个正方体六个面进行染色,现在我们有n种颜色,通过旋转能到达同同一状态的算一种情况,问你一共有多少中不同的染色?

问题分析:裸的polya置换定理,并且是组合数学上的裸的原题,可是在我自己推导的过程中出现了一个非常严重的问题:

我居然在找对称轴的时候,把所有的情况都考虑了一次不动的状态,这个状态只需考虑一次即可。并且由于自己的英语水平不咋的,还连续理解错两次题意。

现在我来详细说明一下解题过程:

(1)找到图中的中心对称轴。

(2)写出不动置换,再写出沿着不同中心对称轴旋转的置换。(注意:旋转角度为0即不动置换,不能对不动置换同时计算多次吗,只能计算一次)

(3)根据polya置换定理代入公式求解。

给出此题的最终公式:

y=1/24*(m^6+3*m^4+12*m^3+8*m^2)  (注:m为可选颜色的个数)

代码就很简单了,注意一下数据范围即可。

你可能感兴趣的:(polya置换,input,colors,integer,each,output,tags)