题目链接

分析:

用的《训练指南》上的方法。详见P17.

从6个面中选一个做顶面,再从剩下的4个面中选1个做正面,则此正方体唯一确定。

需要枚举共6*4=24种。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring> using namespace std; const int maxn = ; int _left[] = {, , , , , };
int up[] = {, , , , , }; char s1[maxn], s2[maxn], s[maxn]; void rot(int *T, char *str) {
char t[maxn];
strcpy(t, str);
for(int i=; i<; i++) str[i] = t[T[i]];
} bool check() {
char t[maxn];
for(int i=; i<; i++) {
strcpy(t, s1);
if(i == ) rot(up, t);
else if(i == ) { rot(_left, t); rot(up, t); }
else if(i == ) { rot(up, t); rot(up, t); }
else if(i == ) { rot(_left, t); rot(_left, t); rot(up, t); }
else if(i == ) { rot(_left, t); rot(_left, t); rot(_left, t); rot(up, t); }
for(int i=; i<; i++) {
rot(_left, t);
if(strcmp(s2, t) == ) return ;
}
} return ;
} int main() { while(gets(s)) {
for(int i=; i<; i++) s1[i] = s[i];
s1[] = '\0'; for(int i=; i<; i++) s2[i-] = s[i];
s2[] = '\0'; if(check()) printf("TRUE\n");
else printf("FALSE\n");
} return ;
}

UVA253 Cube painting(数学)的更多相关文章

  1. [刷题]算法竞赛入门经典(第2版) 4-4/UVa253 - Cube painting

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) #include<iostream> char str[15]; v ...

  2. uva253 Cube painting(UVA - 253)

    题目大意 输入有三种颜色判断两个骰子是否相同 思路(借鉴) ①先用string输入那12个字符,然后for出两个骰子各自的字符串 ②这里用的算法是先找出第一个的三个面与第二个的六个面去比较,如果找到相 ...

  3. UVA 253 Cube painting(暴力打表)

    Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...

  4. uva 253 - Cube painting(相同骰子)

    习题4-4 骰子涂色(Cube painting, UVa 253) 输入两个骰子,判断二者是否等价.每个骰子用6个字母表示,如图4-7所示. 图4-7 骰子涂色 例如rbgggr和rggbgr分别表 ...

  5. Cube painting UVA - 253

     We have a machine for painting cubes. It is supplied with three different colors: blue, red and gre ...

  6. HDU 1220 Cube(数学,找规律)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1220 Cube Time Limit: 2000/1000 MS (Java/Others)    M ...

  7. UVA 253 Cube painting

    大致题意:有三种颜色,一个立方体6面都可以涂一种颜色.现在给出两个每个面都涂好颜色的立方体,判断这两个立方体通过旋转是否相等. 立方体的旋转出来的结果有很多,首先可以0,1,2,3,4,5(顺序是:上 ...

  8. 骰子涂色 (Cube painting,UVa 253)

    题目描述:算法竞赛入门习题4-4  题目思路:1.旋转其中一个骰子进行匹配 2.进行遍历,如果匹配,就进行相对面的匹配 3.三个对立面都匹配即是一样等价的 //没有按照原题的输入输出 #include ...

  9. UVA 253 Cube painting(枚举 模拟)

    题意: 按如图的顺序给定2个骰子的颜色(只有r.b.g三种颜色) 问2个骰子是否一模一样 如 可表示为“rbgggr” 和 “rggbgr”, 第二个就是绕着Z轴顺时针旋转90度与第一个相同的骰子. ...

随机推荐

  1. Eclipse导入Gradle时报错:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

    百度查到http://stackoverflow.com/questions/19794200/gradle-android-and-the-android-home-sdk-location 按照其 ...

  2. PHP 发布两个不用递归的树形数组构造函数(转)

    <?php/** *创建父节点树形数组 * 参数 $ar 数组,邻接列表方式组织的数据 $id 数组中作为主键的下标或关联键名 $pid 数组中作为父键的下标或关联键名 * 返回 多维数组 ** ...

  3. gcc -I -L -l区别

    我们用gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数,下面做个记录: 例: gcc -o hello hello.c -I /home/hello/inc ...

  4. [转] tomcat结合nginx使用小结

    相信很多人都听过nginx,这个小巧的东西慢慢地在吞食apache和IIS的份额.那究竟它有什么作用呢?可能很多人未必了解. 说到反向代理,可能很多人都听说,但具体什么是反向代理,很多人估计就不清楚了 ...

  5. sed 批量替换多个文件里的某个字符/串

    提示: 国际惯例使用前先备份 sed -i "s/a/b/g" `grep 'a' -rl ./`

  6. 自己编写SqlHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  7. Oracle中的over(partition by...)分析函数及开窗函数

    假设有一张表student Name  Score  InsertTime   (Name:姓名  Score:成绩 InsertTime:考试时间) 张三     20    2015-08-08 ...

  8. require.js的使用的坑!

    require.js的使用心德: 都是自我的理解所得: first:为什么使用? 1,web开发js的占用比例越来越大,引入的插件也越来越多,维护困难,一个一个的script的写要废 2,模块开发的需 ...

  9. H5移动端的注意细节

    1. max-width用在pc端页面,max-device-width用在移动设备上 2. device-pixel-ratio 设备像素比 3.设备自己单位-物理单位dp/dip css像素 px ...

  10. Linq101-Projection

    using System; using System.Linq; namespace Linq101 { class Projection { /// <summary> /// This ...