关于c的暴力求解
固定朝上的面为1,那么同一种情况下与1相邻的四个块顺序就是一定的而且只有四种情况
建立一个索引表然后遍历一下就完事了
遍历就完事了
int main(){
int num;
scanf("%d",&num);
int cnt = 0,cn[10000],table[10000][4][4],via[4],a[6],flag = 0,temp;
for(int i = 0;i < num;i++){
cn[i] = 0;
}
for(int i = 0;i < num;i++){
scanf("%d %d %d %d %d %d\n",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]);
for(int j = 1;j < 6;j++){
if(a[j] == 1){
if(j == 2 || j == 4){
temp = a[j];
a[j] = a[0];
a[0] = temp;
temp = a[1];
a[1] = a[j+1];
a[j+1] = temp;
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
else if(j == 3 || j == 5){
int temp = a[j];
a[j] = a[0];
a[0] = temp;
temp = a[1];
a[1] = a[j-1];
a[j-1] = temp;
temp = a[j];
a[j] = a[j-1];
a[j-1] = temp;
}
else{
int temp = a[j];
a[j] = a[0];
a[0] = temp;
temp = a[2];
a[2] = a[3];
a[3] = temp;
}
break;
}
}
if(cnt == 0){
cn[0] = 1;
cnt++;
table[0][0][0] = a[2];
table[0][0][1] = a[4];
table[0][0][2] = a[3];
table[0][0][3] = a[5];
table[0][1][0] = a[4];
table[0][1][1] = a[3];
table[0][1][2] = a[5];
table[0][1][3] = a[2];
table[0][2][0] = a[3];
table[0][2][1] = a[5];
table[0][2][2] = a[2];
table[0][2][3] = a[4];
table[0][3][0] = a[5];
table[0][3][1] = a[2];
table[0][3][2] = a[4];
table[0][3][3] = a[3];//建立第一个索引表
}
else{
via[0] = a[2];
via[1] = a[4];
via[2] = a[3];
via[3] = a[5];
for(int j = 0;j < cnt;j++){
for(int k = 0;k < 4;k++){
if(table[j][k][0] == via[0] && table[j][k][1] == via[1]&& table[j][k][2] == via[2] && table[j][k][3] == via[3]){
cn[j]++;
flag = 1;
break;
}
}
if(flag == 1){
break;
}
}
if(flag == 0){
cn[cnt]++;
table[cnt][0][0] = a[2];
table[cnt][0][1] = a[4];
table[cnt][0][2] = a[3];
table[cnt][0][3] = a[5];
table[cnt][1][0] = a[4];
table[cnt][1][1] = a[3];
table[cnt][1][2] = a[5];
table[cnt][1][3] = a[2];
table[cnt][2][0] = a[3];
table[cnt][2][1] = a[5];
table[cnt][2][2] = a[2];
table[cnt][2][3] = a[4];
table[cnt][3][0] = a[5];
table[cnt][3][1] = a[2];
table[cnt][3][2] = a[4];
table[cnt][3][3] = a[3];
cnt++;
}
else{
flag = 0;
}
}
}
printf("%d\n",cnt);
for(int i = 0;i < cnt;i++){
for(int j = i + 1;j < cnt;j++){
if(cn[i] < cn[j]){
temp = cn[i];
cn[i] = cn[j];
cn[j] = temp;
}
}
}
for(int i = 0;i < cnt;i++){
printf("%d ",cn[i]);
}
return 0;
}