UVA - 10601 Cubes (组合+置换)
来源:互联网 发布:macbookpro必装软件 编辑:程序博客网 时间:2024/04/30 08:29
Description
Problem B
Cubes
You are given 12 rods of equal length. Each of them is colored in certain color. Your task is to determine in how many different ways one can construct a cube using these rods as edges. Two cubes are considered equal if one of them could be rotated and put next to the other, so that the corresponding edges of the two cubes are equally colored.
Input
The first line of input contains T (1≤T≤60), the number of test cases. Then T test cases follow. Each test case consists of one line containing 12 integers. Each of them denotes the color of the corresponding rod. The colors are numbers between 1 and 6.
Output
The output for one test consists of one integer on a line - the number of ways one can construct a cube with the described properties.
Sample Input
Sample Output
3
1 2 2 2 2 2 2 2 2 2 2 2
1 1 2 2 2 2 2 2 2 2 2 2
1 1 2 2 3 3 4 4 5 5 6 6
1
5
312120
Problem source: Bulgarian National Olympiad in Informatics 2003
Problem submitter: Ivaylo Riskov
Problem solution: Ivaylo Riskov, K M Hasan
题意:有12条边,每个边有指定的颜色,组成一个立方体,求种数
思路:参看cxlove GG的博客
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>typedef long long ll;using namespace std;const int maxn = 20;int a[maxn], b[maxn];ll c[maxn][maxn];void init() {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] + c[i-1][j-1];}}ll solve(int k) {ll sum = 1;int n = 0;for (int i = 0; i < 6; i++)if (b[i] % k == 0) {b[i] /= k;n += b[i]; }else return 0;for (int i = 0; i < 6; i++) {sum *= c[n][b[i]];n -= b[i];}return sum;}ll still() {memcpy(b, a, sizeof(a));return solve(1);}ll point() {memcpy(b, a, sizeof(a));return 4*2*solve(3);}ll plane() {memcpy(b, a, sizeof(a));ll ans = 3*2*solve(4);memcpy(b, a, sizeof(a));return ans + 3*solve(2);}ll edge() {ll ans = 0;for (int i = 0; i < 6; i++)for (int j = 0; j < 6; j++) {memcpy(b, a, sizeof(b));b[i]--, b[j]--;if (b[i] < 0 || b[j] < 0)continue;ans += 6 * solve(2);}return ans;}ll polya() {ll ans = 0;ans += still();ans += point();ans += plane();ans += edge();return ans / 24;}int main() {init();int t, k;scanf("%d", &t);while (t--) {memset(a, 0, sizeof(a));for (int i = 0; i < 12; i++) {scanf("%d", &k);a[k-1]++;}printf("%lld\n", polya());}return 0;}
- UVA - 10601 Cubes (组合+置换)
- uva 10601 - Cubes(置换)
- UVA 10601 Cubes (组合数学 + ploya计数)
- uva 10733 - The Colored Cubes(置换)
- UVA - 10733 The Colored Cubes (置换)
- Uva 10601 Cubes(polya计数)
- UVA 10601 Cubes
- uva 10601 Cubes (polya)
- UVA 10601 Cubes (Polya计数)
- uva10601 - Cubes 正方体置换
- UVA 10601 CUBES (正方体Polya,有限制)
- UVA 10601 CUBES (正方体Polya,有限制)
- UVA 10601 Cubes(正方体旋转、Polya计数)
- UVA 10601 Cubes (Polya定理+Burnside引理)
- UVA 10601 CUBES (正方体Polya,有限制)
- Cubes UVA
- uva 1352 - Colored Cubes(枚举)
- uva 10051 Tower of Cubes(dp)
- Java编程思想(七) —— 内部类
- ACdream 1108 分块
- android编程异常解决 FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #195: Erro
- 用模板写选择排序-链表
- 求二叉树中节点的最大距离
- UVA - 10601 Cubes (组合+置换)
- String to Integer (atoi)
- ZOJ Problem Set - 2750
- Android开源项目QuickReturnHeader分析
- Reverse Words in a String
- ssh 搭建
- HDU4592 Boring Game (2013 ACM-ICPC南京赛区全国邀请赛) 高斯消元
- POJ 2236Wireless Network
- USACO Humble Number