Dice

http://acm.hdu.edu.cn/showproblem.php?pid=5012

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2352    Accepted Submission(s): 1178

Problem Description
There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6 to be numbers written on top face, bottom face, left face, right face, front face and back face of dice A. Similarly, consider b1.b2,b3,b4,b5,b6 to be numbers on specific faces of dice B. It’s guaranteed that all numbers written on dices are integers no smaller than 1 and no more than 6 while ai ≠ aj and bi ≠ bj for all i ≠ j. Specially, sum of numbers on opposite faces may not be 7.

At the beginning, the two dices may face different(which means there exist some i, ai ≠ bi). Ddy wants to make the two dices look the same from all directions(which means for all i, ai = bi) only by the following four rotation operations.(Please read the picture for more information)


Now Ddy wants to calculate the minimal steps that he has to take to achieve his goal.

 
Input
There are multiple test cases. Please process till EOF.

For each case, the first line consists of six integers a1,a2,a3,a4,a5,a6, representing the numbers on dice A.

The second line consists of six integers b1,b2,b3,b4,b5,b6, representing the numbers on dice B.

 
Output
For each test case, print a line with a number representing the answer. If there’s no way to make two dices exactly the same, output -1.
 
Sample Input
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 5 6 4 3
1 2 3 4 5 6
1 4 2 5 3 6
 
Sample Output
0
3
-1
 
Source
 
模拟搜索水题
 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdio>
#include<queue>
#include<map>
#include<vector>
typedef long long ll;
#define maxn 100005
using namespace std; int a[],b[];
map<int,int>mp;
struct sair{
int num,step;
}; sair Roll(sair tmp,int x){
//左右前后
sair ans;
ans.num=;
int aa[];
int xx=tmp.num;
for(int i=;i>=;i--){
a[i]=xx%;
xx/=;
}
if(x==){
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
else if(x==){
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
else if(x==){
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
else{
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
ans.step=tmp.step+;
return ans;
} void bfs(int S,int E){
sair s,e;
if(S==E){
cout<<<<endl;
return;
}
s.num=S,s.step=;
queue<sair>Q;
Q.push(s);
while(!Q.empty()){
s=Q.front();
Q.pop();
for(int i=;i<;i++){
e=Roll(s,i);
if(e.num==E){
cout<<e.step<<endl;
return;
}
if(!mp[e.num]){
Q.push(e);
mp[e.num]=;
}
}
}
cout<<-<<endl;
} int main(){
while(cin>>a[]){
mp.clear();
for(int i=;i<=;i++) cin>>a[i];
int S=,E=;
for(int i=;i<=;i++) E=E*+a[i];
for(int i=;i<=;i++) cin>>b[i];
for(int i=;i<=;i++) S=S*+b[i];
bfs(S,E);
}
}

Dice的更多相关文章

  1. HDOJ 4652 Dice

      期望DP +数学推导 Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  2. 三种renderman规范引擎的dice对比

    次表面做的有些烦躁,既然如此,索性先记一下前一阵比较的PIXIE.3delight.prman的dice方式. 研究过reyes的人都知道dice,简而言之,就是为了生成高质量高精度的图片(电影CG) ...

  3. LightOJ 1248 Dice (III) 概率

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  4. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  5. 概率 Gym 100502D Dice Game

    题目传送门 /* 题意:两个人各掷两个骰子,给出每个骰子的最小值和最大值,其余值连续分布 问两人投掷,胜利的概率谁大 数据小,用4个for 把所有的可能性都枚举一遍,统计每一次是谁胜利 还有更简单的做 ...

  6. HDU 5955 Guessing the Dice Roll

    HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...

  7. UVALive 7275 Dice Cup (水题)

    Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...

  8. HDU 4586 A - Play the Dice 找规律

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. CF Polycarpus' Dice (数学)

    Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  10. [LOJ 1248] Dice (III)

    G - Dice (III) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Descri ...

随机推荐

  1. mysql实战优化之九:MySQL查询缓存总结

    mysql Query Cache 默认为打开.从某种程度可以提高查询的效果,但是未必是最优的解决方案,如果有的大量的修改和查询时,由于修改造成的cache失效,会给服务器造成很大的开销. mysql ...

  2. dede:channel的type改为son,currentstyle当前样式就不起作用

    我在修改得闲佬设计作品展示列表页的时候,遇到一个问题,就是channel的type改为son时,currentstyle属性不起作用,试了好久都没办法,后来上网找资料,就找到了解决方法,记录一下.   ...

  3. git如何查看某个人提交的日志。

    我们知道,在git进行cherry-pick的时候,找到commit id是至关重要, 如果我们是很多人在一个分支开发,开发完了之后,发现某个人的功能,需要单独cherry-pick到另外一分支上去. ...

  4. Impala源码分析

    问题导读:1.Scheduler任务中Distributed Plan.Scan Range是什么?2.Scheduler基本接口有哪些?3.QuerySchedule这个类如何理解?4.Simple ...

  5. CentOS7 安装supervisor守护进程管理器

    supervisor没有发布在标准的CentOS源在,需要安装epel源.这种方式安装的可能不是最新版本,但比较方便,安装完成之后,配置文件会自动帮你生成. 默认配置文件:/etc/superviso ...

  6. HP-UX oracle RAC 双机实践 (转载)

    一.软硬件配置检查 1.检查内存#/usr/contrib/bin/machinfoCPU info:  4 Intel(R) Itanium 2 9100 series processors (1. ...

  7. Hive基础之Hive表常用操作

    本案例使用的数据均来源于Oracle自带的emp和dept表 创建表 语法: CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name ...

  8. java impl

    java impl 是一个资源包,用来存放java文件的.在Java开发中,通常将后台分成几层,常见的是三层mvc:model.view.controller,模型视图控制层三层,而impl通常处于c ...

  9. SpringBoot入门篇--热部署

    在项目的开发过程中我们难免会涉及到对代码的修改,有bug我们也需要对代码进行修改,这时候我们就需要重启服务器.但是,我们知道的是这个过程是相当的痛苦的,重启服务器涉及到了所有资源的重新加载,过程那是相 ...

  10. leetcode202

    public class Solution { private int SumSqares(int n) { //将一个数字的各个数位的值分开存储 var list = new List<int ...