UVA10601 Cubes
阿新 • • 發佈:2018-12-19
Cubes
題意
給出根長度相等的木棒,顏色最多有種,問能構成的本質不同的正方體數量.
題解
根據波利亞定理公式:
設X是元素集合,G是X的置換群,是種顏色的集合,是的任意著色集.這時,針對各顏色的數目的C的非等價著色數的生成函式是:
-
我們先求出根木棒的顏色數,假設有中,每種顏色假設有個,注意.
-
求出置換群. 眾所周知的,正方體的置換群大小是. (1)恆等變換:個 (2)繞對面的中心旋轉度:個. (3)繞對邊的中點連成的軸旋轉度:個. (4)繞體對角線旋轉度:個. 根據上述四種情況得到的關於線元素的置換平均值為:
-
將代入式.那麼答案就是函式的前的係數
-
函式的每一項都是形如的,我要對每個這樣的式子,求前的係數之和.每個項單獨進行就可以了.
程式碼
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>
#define pr(x) std::cout << #x << ':' << x << std::endl
#define rep(i,a,b) for(int i = a;i <= b;++i)
int T;
int tc[7],x[7],ox[7];
int C[13][13];
void init() {
C[0][0] = 1;
rep(i,1,12) {
C[i][0] = 1;
rep(j,1,i) {
C[i][j] = C[i-1][j] + C[i-1][j-1];
}
}
}
int ans = 0;
void dfs(int dep,int mul) {
if(dep == 5) {
int f = 0;
rep(i,1,6) f += x[i];
if(!f) {
ans += mul;
}
return ;
}
int tx[7];
rep(i,1,6) tx[i] = x[i];
for(int x1 = 0;x1 <= tc[dep] && dep * x1 <= tx[1];++x1) {
int res1 = C[tc[dep]][x1];
for(int x2 = 0;x2 <= tc[dep] - x1 && dep*x2 <= tx[2];++x2) {
int res2 = res1 * C[tc[dep]-x1][x2];
for(int x3 = 0;x3 <= tc[dep]-x1-x2 && dep*x3 <= tx[3];++x3) {
int res3 = res2 * C[tc[dep]-x1-x2][x3];
for(int x4 = 0;x4 <= tc[dep]-x1-x2-x3 && dep*x4 <= tx[4];++x4) {
int res4 = res3 * C[tc[dep]-x1-x2-x3][x4];
for(int x5 = 0;x5 <= tc[dep]-x1-x2-x3-x4 && dep*x5 <= tx[5];++x5) {
int res5 = res4 * C[tc[dep]-x1-x2-x3-x4][x5];
int x6 = tc[dep]-x1-x2-x3-x4-x5;
//pr(x1);pr(x2);pr(x3);pr(x4);pr(x5);pr(x6);
if(dep*x6 <= tx[6]) {
x[1] = tx[1] - dep*x1;x[2] = tx[2] - dep*x2;
x[3] = tx[3] - dep*x3;x[4] = tx[4] - dep*x4;
x[5] = tx[5] - dep*x5;x[6] = tx[6] - dep*x6;
dfs(dep+1,res5*mul);
}
}
}
}
}
}
}
int main() {
init();
std::ios::sync_with_stdio(false);
std::cin >> T;
while(T--) {
memset(ox,0,sizeof(ox));
rep(i,1,12) {
int tmp;
std::cin >> tmp;
ox[tmp] ++;
}
int res = 0;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = 12,tc[2] = tc[3] = tc[4] = 0;
dfs(1,1);
res += ans;
rep(i,1,6) x[i] = ox[i];
ans = 0;
tc[1] = tc