# UVA10733 The Colored Cubes【Polya定理】

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

AC的C++语言程序如下：

/* UVA10733 The Colored Cubes */

#include <bits/stdc++.h>

typedef long long LL;

inline LL pow(int n, int k)
{
LL ret = 1;
for(int i = 1; i <= k; i++)
ret *= n;
return ret;
}

inline LL polya(int n)
{
LL sum = 0;
sum += pow(n, 6) + 3 * pow(n, 4) + 12 * pow(n, 3) + 8 * pow(n, 2);
return sum;
}

int main()
{
int n;
while(~scanf("%d", &n) && n)
printf("%lld\n", polya(n) / 24);

return 0;
}


08-15 14

07-19 1091
03-09 756
08-13 326
05-03 1566
08-14 896
09-17 1173
03-18 690
08-03 60