codeforces #78 div2 C
来源:互联网 发布:上海 java 培训机构 编辑:程序博客网 时间:2024/04/29 14:47
http://www.codeforces.com/contest/99/problem/C
题意就是问给出了6个颜色(可以相同)涂一个正方体,问能组成多少种不同的情况,注:能旋转的就视为同一种情况
方法:模拟正方体旋转,可以拿一块橡皮试试,例如规定0-前,1-后,2-左,3-右,4-下,5上,依次旋转。
#include<iostream>#include<vector>#include<map>#include<stack>#include<algorithm>#include<queue>#include<list>#include<set>#include<string.h>#include<stdlib.h>#include<math.h>#include<stdio.h>#include<ctype.h>#include<iomanip>using namespace std;#define LL long long#define L long#define pi acos(-1)#define N 1100#define INF 9999999999#define eps 1e-8string str[] = { "012345", "041235", "034125", "023415", "104523", "120453", "152043", "145203", "215304", "201534", "230154", "253014" };bool equal(string a, string b){ for(int i = 0 ; i < 12; i++) { string t1; for(int j = 0; j < 6; j++) t1 += a[ str[i][j] - '0' ]; if( t1 == b ) return true; string rev = str[i]; reverse(rev.begin(), rev.end() ); string t2; for(int j = 0 ; j < 6; j++) t2 += a[ rev[j] - '0']; if( t2 == b ) return true; } return false;}int main(){ //freopen("a.txt","r",stdin); string s; while(cin >> s) { sort(s.begin(), s.end()); vector<string> myset; do { bool already = false; for(int i = 0; i < myset.size(); i++) if( equal(s, myset[i] ) ) { already = true; break; } if( !already ) myset.push_back(s);//cout<<s<<endl; }while(next_permutation(s.begin(), s.end())); cout<<myset.size()<<endl; } return 0;}
- codeforces #78 div2 C
- codeforces 148 div2 C
- codeforces #169 div2 C
- codeforces 170 div2 C
- codeforces 178div2 C
- Codeforces Round225 DIV2 C
- codeforces 256 div2 C
- Codeforces #263 Div2 C
- codeforces 294 div2.C
- CODEFORCES #339 div2 C
- codeforces #Round354-div2-C
- Codeforces #409div2 C
- CodeForces-428-div2-c
- codeforces #72 div2 C. Biathlon
- codeforces #16 div2 C.monitor
- codeforces 171 div2 C&E
- CodeForces #174.div2.problem C
- CodeForces #181.div2.problem C
- 如何写出可维护面向对象的JS?
- 黑马程序员Java培训和Android培训:编程基础
- 程序员经典电子书下载(超全)
- 浅谈NAT的原理缺陷及其解决之道
- Android 类iphone的Expandable List View
- codeforces #78 div2 C
- Mongodb配置
- 伤得起 screen breaker
- 算法系列之三:妖怪与和尚过河问题
- 数据的表示和运算
- 网络地址转换NAT原理及应用
- 追寻人生的意义
- 道理最大
- listings 宏包札记