10601 - Cubes(Ploya)
UVA 10601 - Cubes
题意:给定正方体12条棱的颜色,要求用这些棱能组成多少不同的正方体
思路:利用ploya定理去求解,分类讨论,正方体一共24种旋转。相应的旋转方式有4种:
1、不动
2、沿两面中点连线旋转
3、沿对顶点连线旋转
4、沿两棱中点连线旋转
简单推算出每种情况相应的循环组数。在加上组合数学去进行选择颜色求解。注意第4种情况中,有两条棱和其它的循环长度是不同的,能够枚举然后扣掉讨论。
代码:
#include <stdio.h>
#include <string.h> int t, color[6], save[6], c[13][13]; long long solve(int k) {
long long sum = 0, ans = 1;
for (int i = 0; i < 6; i++) {
if (save[i] % k) return 0;
save[i] /= k;
sum += save[i];
}
for (int i = 0; i < 6; i++) {
ans *= c[sum][save[i]];
sum -= save[i];
}
return ans;
} long long solve1() {
memcpy(save, color, sizeof(save));
return solve(1);
} long long solve2() {
memcpy(save, color, sizeof(save));
long long ans = 6 * solve(4);
memcpy(save, color, sizeof(save));
return ans + 3 * solve(2);
} long long solve3() {
memcpy(save, color, sizeof(save));
return 8 * solve(3);
} long long solve4() {
long long ans = 0;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
memcpy(save, color, sizeof(save));
save[i]--; save[j]--;
if (save[i] < 0 || save[j] < 0) continue;
ans += 6 * solve(2);
}
}
return ans;
} int main() {
for (int i = 0; i <= 12; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++)
c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
}
scanf("%d", &t);
while (t--) {
int col;
memset(color, 0, sizeof(color));
for (int i = 0; i < 12; i++) {
scanf("%d", &col);
color[col - 1]++;
}
printf("%lld\n", (solve1() + solve2() + solve3() + solve4()) / 24);
}
return 0;
}
10601 - Cubes(Ploya)的更多相关文章
- UVA 10733 - The Colored Cubes(Ploya)
UVA 10733 - The Colored Cubes 题目链接 题意:一个立方体.n种颜色,问能涂成多少不同立方体 思路:Ploya求解,正方体相应24种不同旋转一一计算出循环个数就可以.和 U ...
- 组合数学(Pólya计数原理):UvaOJ 10601 Cubes
Cubes You are given 12 rods of equal length. Each of them is colored in certain color. Your task is ...
- UVa 10601 (Polya计数 等价类计数) Cubes
用6种颜色去染正方体的12条棱,但是每种颜色都都限制了使用次数. 要确定正方体的每一条棱,可以先选择6个面之一作为顶面,然后剩下的四个面选一个作为前面,共有24种. 所以正方体的置换群共有24个置换. ...
- 一位学长的ACM总结(感触颇深)
发信人: fennec (fennec), 信区: Algorithm 标 题: acm 总结 by fennec 发信站: 吉林大学牡丹园站 (Wed Dec 8 16:27:55 2004) AC ...
- 数学3(博弈+splya)
数学3(博弈+splya) 标签: 数学 hdu_5194 (打表找规律) 题意 有n和黑球和m个白球,现在一个个的取出这些球,如果是黑球则当前标记为1,白球为0,那么当取完这些球会得到一些序列.问你 ...
- polya burnside 专题
polya题目:uva 11077 Find the Permutationsuva 10294 Arif in DhakaLA 3641 Leonardo's Notebookuva 11077 F ...
- 水泡动画模拟(Marching Cubes)
Marching Cubes算法是三维离散数据场中提取等值面的经典算法,其主要应用于医学领域的可视化场景,例如CT扫描和MRI扫描的3D重建等. 算法主要的思想是在三维离散数据场中通过线性插值来逼近等 ...
- Codeforces525E Anya and Cubes(双向搜索)
题目 Source http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Toda ...
- [saiku] 系统登录成功后查询Cubes
一.系统启动时初始化ds和conn 1.查询出目前系统拥有的Datasources和Connections放入内存中 2.比对saiku-datasources中的ds是否有新增的,如果有,创建新的d ...
随机推荐
- js事件 (包含call()方法使用特点)
1.焦点事件 获取焦点事件onfocus\失去焦点事件onblur 例: oText.onfocus=function(){} 焦点:使浏览器能够区分用户输入的对象,当一个元素有焦点的时候,那么它就可 ...
- LeetCode(15) 3Sum
题目 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all ...
- LeetCode 464. Can I Win
In the "100 game," two players take turns adding, to a running total, any integer from 1.. ...
- ASP.NET MVC中如何在客户端进行必要的判断
背景:在开发网站时,往往需要对用户的输入进行合法性检查,如果验证工作都放在服务器端,势必将影响网页的响应速度,同时给用户不好的体验.本篇随笔即是使用JQuery在客户端进行必要的合法检测. JS代码如 ...
- HDU-1020-Encoding,题意不清,其实很水~~
Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) http:// ...
- 从零到一,使用实时音视频 SDK 一起开发一款 Zoom 吧
zoom(zoom.us) 是一款受到广泛使用的在线会议软件.相信各位一定在办公.会议.聊天等各种场景下体验或者使用过,作为一款成熟的商业软件,zoom 提供了稳定的实时音视频通话质量,以及白板.聊天 ...
- Ubuntu安装sublime Text 3并配置可以输入中文
使用Ubuntu系统后,想找一个顺手的编辑器,sublime作为我的首选编辑器,在安装和配置可输入中文时遇到各种个样的问题,总结一些: 1:问题: 我的系统是Ubuntu 18.04 LTS,尝试多次 ...
- Gym 215177D 母亲节的礼物
Gym 215177D 母亲节的礼物 Problem : 给n个点m条边的无向图,每个点的度数小于等于7,要求用4种不同的颜色给每个点染色,使得每个点相邻的点中最多只有一个相同颜色的点.(n<= ...
- 原 ELK+Filebeat集中式日志解决方案(centos7)
https://blog.csdn.net/bittersweet0324/article/details/78503961
- 从零开始写STL—模板元编程之tuple
tuple Class template std::tuple is a fixed-size collection of heterogeneous values. It is a generali ...