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 ...
随机推荐
- Spring AOP 详细介绍
一.理解 “面向切面编程” 面向切面编程(Aspect Oriented Programming,AOP)是软件编程思想发展到一定阶段的产物,是对面向对象编程(Object Oriented Prog ...
- docker的网络(基础)
Docker的网络子系统是可插拔的,使用驱动程序.默认情况下存在多个驱动程序,并提供核心网络功能: bridge:docker默认的网络驱动.如果未指定驱动程序,则这是需要创建的网络类型.当应用程序在 ...
- pwnable.kr lotto之write up
源代码 : #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcnt ...
- 杭电 2647 Reward (拓扑排序反着排)
Description Dandelion's uncle is a boss of a factory. As the spring festival is coming , he wants to ...
- [工具]Visual Studio
1,Tab键的使用: 如不说有这样的代码:public Member member { get; set; } 当我们编辑完Member后,按一下Tab键,就能够将光标锁定到member上,等待键盘输 ...
- idea 中的svn的使用
http://www.cnblogs.com/whc321/p/5669804.html 很详细
- CDOJ 1217 The Battle of Chibi
The Battle of Chibi Time Limit: 6000/4000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Othe ...
- xtu read problem training 2 B - In 7-bit
In 7-bit Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 3 ...
- python3--shelve 模块
shelve模块是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式 import shelve d = shelve.open('shelve_t ...
- 生产环境下lnmp的权限说明
https://www.cnblogs.com/zrp2013/p/4183546.html 有关权限说明:-rwxrw-r‐-1 root root 1213 Feb 2 09:39 50.html ...