题意:给定两个16进制数,问你把它转成二进制后,把第一个向左或者向右旋转最少的次数同,使得第一个变成第二个。

析:也是比较水的,按照要求做就好,注意0的情况,可能会忘记。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define frer freopen("in.txt", "r", stdin)
#define frew freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
int T; cin >> T;
for(int kase = 1; kase <= T; ++kase){
string s = "", t = "";
string s1;
cin >> s1;
while(s1.size() < 8) s1 = "0" + s1;
for(int i = 0; i < 8; ++i){
if(isdigit(s1[i])){
s += (string)de[s1[i]-'0'];
}
else s += (string)de[s1[i]-'A'+10];
}
cin >> s1;
while(s1.size() < 8) s1 = "0" + s1;
for(int i = 0; i < 8; ++i){
if(isdigit(s1[i])){
t += (string)de[s1[i]-'0'];
}
else t += (string)de[s1[i]-'A'+10];
}
int cnt1 = 0, cnt2 = 0;
for(int i = 0; i <= 32; ++i){
if(s[i] == '1') ++cnt1;
if(t[i] == '1') ++cnt2;
}
if(cnt1 != cnt2){ printf("Case #%d: Not possible\n", kase); continue; }
int ans = 0;
string ss = s;
while(true){
if(s == t) break;
s.push_back(s[0]);
s.erase(s.begin());
++ans;
if(ans > 35) break; } int ans2 = 0;
while(true){
if(ss == t) break;
char ch = ss[31];
ss = ch + ss;
ss.resize(32);
++ans2;
if(ans2 > 35) break; }
if(ans > 35 && ans2 > 35) printf("Case #%d: Not possible\n", kase);
else if(ans < ans2) printf("Case #%d: %d Left\n", kase, ans);
else if(ans == ans2) printf("Case #%d: %d Any\n", kase, ans);
else printf("Case #%d: %d Right\n", kase, ans2);
}
return 0;
}

  

UVaLive 6809 Spokes Wheel (模拟)的更多相关文章

  1. UVALive - 6269 Digital Clock 模拟

    UVALive - 6269 Digital Clock 题意:时钟坏了,给你一段连续的时间,问你现在可能的时间是多少. 思路:直接模拟,他妈的居然这场就跪在了这题,卧槽,他妈的就在111行,居然多打 ...

  2. UVALive - 7139(差分+模拟)

    题目链接 参考 题意 N*M的网格,一辆车沿着网格线按给定路线走,每个网格里有一个人,人的视线始终看着车,问这些人净转圈数的平方和. 分析 由于车的起点和终点都为左上角,且每个格子里的人永远面对着车, ...

  3. UVALive 7464 Robots(模拟)

    7464Robots Write a program to collect data from robots. We are given two sets of robotsX=fX1;:::;Xmg ...

  4. 【Bit String Reordering UVALive - 6832 】【模拟】

    题意分析 题目讲的主要是给你一个01串,然后给你要变成的01串格式,问你要转换成这一格式最少需要移动的步数. 题目不难,但当时并没有AC,3个小时的个人赛1道没AC,归根到底是没有逼自己去想,又想的太 ...

  5. 【Miscalculation UVALive - 6833 】【模拟】

    题目分析 题目讲的是给你一个串,里面是加法.乘法混合运算(个人赛中误看成是加减乘除混合运算),有两种算法,一种是乘法优先运算,另一种是依次从左向右运算(不管它是否乘在前还是加在前). 个人赛中试着模拟 ...

  6. UVALive 6858 Frame (模拟)

    Frame 题目链接: http://acm.hust.edu.cn/vjudge/contest/130303#problem/D Description http://7xjob4.com1.z0 ...

  7. Wheel ProgressBar 实现之三——模拟进度过程

    1. 效果展示: 知道如何画圆弧,如何精确画出进度文本之后,我们将进入 Wheel ProgressBar 实现的最后一个过程:模拟其动态呈现过程.如下图所示,初始时显示进度为 0 (上图),点击进度 ...

  8. 模拟/字符串处理 UVALive 6833 Miscalculatio

    题目传送门 /* 模拟/字符串处理:主要是对*的处理,先把乘的预处理后再用加法,比如说是:1+2*3+4 = 1+..6+4 = 11 */ #include <cstdio> #incl ...

  9. UVALive 6093 Emergency Room --优先队列实现的模拟

    题意:给n个医生,这些医生有一个上班时间,然后给一些病人,病人有一个到达的时间,以及一些诊断,诊断有property(优先级)和duration(诊断时间)这两个属性,每个病人可能要诊断多次,最后问每 ...

随机推荐

  1. jquery 连写注释;siblings() 方法;jQuery 的3种滑动方法;slideUp()向上滑动;slideDown()向下滑动;slideToggle()来回滑动

    首先我们看两个连写注释 第一个:   /* 点击头像,显示基本资料 */ $(".f-chatTit a.avatar").click(function(){ $(this).hi ...

  2. linux CPU loading calculate

    http://hi.baidu.com/lionpanther/item/e908c37abdaf1c3f71442380 #include <stdio.h>#include <s ...

  3. java注解Annotation

    扯扯注解的蛋 为什么学习注解?学习注解有什么好处?学完能做什么? 1.能够读懂别人的代码,特别是框架相关的代码 2.让编程更加简洁,代码更加清晰 3.让别人高看你一眼 注解是java1.5引入的 概念 ...

  4. XE7 - 程序图标及启动画面图片的注意事项

    还是继续昨晚写的,年前已经解决了这个问题,现在补记下.启动画面失真是本篇笔记的重点.搜索了很多文章,基本上大同小异,几乎都没怎么提及启动画面失真的问题.不知道是不是我的操作不对头,. Project ...

  5. 【英语】Bingo口语笔记(42) - Got系列

  6. aspose.Cells 导出Excel

    aspose aspse.Cells可以操作Excel,且不依赖于系统环境. 使用模板,通过绑定输出数据源 这种适合于对格式没有特别要求的,直接绑定数据源即可.和数据绑定控件差不多. Workbook ...

  7. ORACLE TM锁

    Oracle的TM锁类型 锁模式 锁描述 解释 SQL操作 0 none 1 NULL 空 Select 2 SS(Row-S) 行级共享锁,其他对象只能查询这些数据行 Select for upda ...

  8. Range类中的三个方法及简单打印

    package pkgFirst; import org.junit.Test; public class Range{ /** * FunName: println * Description : ...

  9. 笔记《Java程序性能优化 让你的Java程序更快、更稳定》 第二章 设计调优

    2.1 善用设计模式 23 (1) 1. 设计模式好处: 2.1.1 单例模式 23 (6) 1. 单例模式是一种对象创建模式,用于产生一个对象的具体实例,它可以确保系统中一个类只产生一个实例: 2. ...

  10. grails下的httpclient

    httpclient已经发布到4.3版本了,其中的API发生了巨大的变化,尤其是对于关闭连接显得更加容易理解,比如引入了CloseableHttpResponse. 然而grails2.3.2中自带了 ...