UVA 253 Cube painting
来源:互联网 发布:淘宝类目搜索怎么填 编辑:程序博客网 时间:2024/04/26 10:26
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, or g. 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
题意:输入12个字符。,前6个代表第一个骰子,后六个代表第二个骰子。r、b、g分别代表红,蓝,绿。。
要判断第一个骰子和第二个骰子是不是一样的骰子(即骰子是可以旋转的。。旋转后一样的为相同骰子。。
解法:暴力。。骰子的面可以分为3组。如果在第二个骰子能找到3组和第一个骰子一样的两个对立面。。2个骰子肯定是一样的。。。注意:如果一组面。要把找过的面标记掉。防止找下一组面的时候重复。。。
#include<stdio.h>char sb[13];char s1[7];char s2[7];int judge;void in(){int i;for (i = 0; i < 6; i ++)s1[i] = sb[i];for (i = 6; i < 12; i ++)s2[i - 6] = sb[i];}void ju(){int i, j;for (i = 0; i < 3; i ++){judge = 0;for (j = 0; j < 6; j ++){if (s1[i] == s2[j] && s1[5 - i] == s2[5 - j]){s2[j] = s2[5 - j] = '\0';judge = 1;break;}}if (judge == 0)break;}}int main(){while (gets(sb) != NULL){in();ju();if (judge)printf("TRUE\n");elseprintf("FALSE\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
- ORA-04031: unable to allocate 2048024 bytes of shared memory
- 图解vs2008打包全过程,含卸载功能的介绍
- $(this)和this、index() 、.hover()
- linux命令(1):ls命令
- 随笔记录
- UVA 253 Cube painting
- 【念7.30】该成长的项目
- 如何让一行文本显示一定的宽度,超出省略号代替
- socket10053
- Solution to 0–1 Knapsack Problem
- linux命令(2):cd命令
- 得到元素的内存地址
- this用法的简单示例
- opengl super bible(超级宝典)第五版阅读笔记