UVa 253 - Cube painting
来源:互联网 发布:淘宝要怎么运营 编辑:程序博客网 时间:2024/04/25 10:13
Cube painting
We have a machine for painting cubes. It is supplied with three different colors: blue, red and green. Each face of the cube gets one of these colors. The cube's faces are numbered as in Figure 1.
Figure 1.
Since a cube has 6 faces, our machine can paint a face-numbered cube in different ways. When ignoring the face-numbers, the number of different paintings is much less, because a cube can be rotated. See example below. We denote a painted cube by a string of 6 characters, where each character is a b, r, org. The character ( ) from the left gives the color of face i. For example, Figure 2 is a picture of rbgggr and Figure 3 corresponds to rggbgr. Notice that both cubes are painted in the same way: by rotating it around the vertical axis by 90 , the one changes into the other.
Input
The input of your program is a textfile that ends with the standard end-of-file marker. Each line is a string of 12 characters. The first 6 characters of this string are the representation of a painted cube, the remaining 6 characters give you the representation of another cube. Your program determines whether these two cubes are painted in the same way, that is, whether by any combination of rotations one can be turned into the other. (Reflections are not allowed.)
Output
The output is a file of boolean. For each line of input, output contains TRUE if the second half can be obtained from the first half by rotation as describes above, FALSE otherwise.
Sample Input
rbgggrrggbgrrrrbbbrrbbbrrbgrbgrrrrrg
Sample Output
TRUEFALSEFALSE
这道题目穷举一下所有的情况就可以,一共是24种情况,分别取每个面作为上面,然后在进行旋转,旋转时每个面会对应四种情况
这样一共就是6*4=24种情况
代码:
#include <stdio.h>#include <string.h>int a[30][6]={{},{1,2,3,4,5,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{1,3,5,2,4,6}, {6,2,4,3,5,1},{6,3,2,5,4,1},{6,5,3,4,2,1},{6,4,5,2,3,1}, {2,6,3,4,1,5},{2,4,6,1,3,5},{2,1,4,3,6,5},{2,3,1,6,4,5}, {5,6,4,3,1,2},{5,3,6,1,4,2},{5,1,3,4,6,2},{5,4,1,6,3,2}, {3,2,6,1,5,4},{3,1,2,5,6,4},{3,5,1,6,2,4},{3,6,5,2,1,4}, {4,2,1,6,5,3},{4,6,2,5,1,3},{4,5,6,1,2,3},{4,1,5,2,6,3} };int main(){ int i,j,n,m,s,t; char s1[20],s2[20]; while(scanf("%s",s1)!=EOF) { for(i=6;i<=12;i++) { s2[i-6]=s1[i]; } for(i=1;i<=24;i++) { for(j=0;j<=5;j++) { if(s2[j]==s1[a[i][j]-1]) { ; }else { break; } } if(j==6) { break; } } if(i==25) { printf("FALSE\n"); }else { printf("TRUE\n"); } } return 0;}
- UVa 253 - Cube painting
- Uva 253 - Cube painting
- Uva 253 Cube Painting
- uva 253 Cube painting
- uva 253 - Cube painting
- UVa 253 - Cube painting
- UVA 253 - Cube painting
- UVA 253 - Cube painting
- UVA 253 Cube painting
- UVa 253: Cube painting
- uva 253 - Cube painting
- uva 253 Cube painting
- UVA 253 Cube painting
- 253 - Cube painting UVA
- UVa 253 Cube painting
- UVA-253-Cube painting
- UVa 253 - Cube painting
- UVA 253 Cube painting
- 什么是REST?以及RESTful的实现
- Android实现ListView圆角效果
- Ubuntu 10.04 右上角网络管理图标消失的解决办法
- myeclipse中项目不编译解决方法
- _ttoi()与_itot_s()
- UVa 253 - Cube painting
- 一步一步复习数据结构和算法基础-哈希表的链地址表示
- Zookeeper全解析——Paxos作为灵魂
- 关于C++的接口类
- NDK的Windwos环境搭建
- C++中抽象类和接口类的区别
- 自定义UITableViewCell,实现类似QQ好友列表
- ThinkPad T61风扇转速控制方法
- 编程语言