题意:给定两个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. I.MX6 Android backlight modify by C demo

    /************************************************************************** * I.MX6 Android backligh ...

  2. Centos移除图形界面

    在此之前为了试验SAS Linux,在一台centos服务器上安装了desktop界面, 目前需要删除这些界面组件,可以按照以下步骤实现: 1. yum grouplist查看安装的组件 2. 使用y ...

  3. 摘录:官方文档对ROWID虚拟行的定义

    ROWID Pseudocolumn For each row in the database, the ROWID pseudocolumn returns the address of the r ...

  4. Heritrix源码分析(十一) Heritrix中的URL--CandidateURI和CrawlURI以及如何增加自己的属性(转)

    本博客属原创文章,欢迎转载!转载请务必注明出处:http://guoyunsky.iteye.com/blog/649889 本博客已迁移到本人独立博客: http://www.yun5u.com/ ...

  5. 【转】Bootloader之uBoot简介(转)

    原文网址:http://blog.csdn.net/sadamoo/article/details/8139946 来自http://blog.ednchina.com/hhuwxf/1915416/ ...

  6. Javascript高级程序设计

    根据叶小钗同学的建议,觉得有必要去读读Javascript高级程序设计,不想装B,只想仔细读读,源代码参考. 偶第一个想法,就是去读面向对象和事件那块,不仅关键,而且是薄弱点儿,所以必须去干掉这个短板 ...

  7. java web项目导入问题

    由于工作问题,接触到很多其他人的项目,有时候想要直接跑起来,还是需要一定的耐力. 1:导入不进去,干脆新建项目,一个个复制进去: 2:第三方jar包不要忘记,核实jdk    j2ee的版本,编译路径 ...

  8. Word2003使用VBA教程

    [正文] 注:本文中所有vba代码都是储存在doc中,而非normal.dot 1.打开一个.doc文档 2.按ALT+F11 3.左侧 Project-插入-模块 4.输入自己的代码,一定要是函数的 ...

  9. 浅谈MySQL Replication(复制)基本原理

    1.MySQL Replication复制进程MySQL的复制(replication)是一个异步的复制,从一个MySQL instace(称之为Master)复制到另一个MySQL instance ...

  10. Supervisor行为分析和实践

    1.简介     Erlang要编写高容错性.稳定性的系统,supervisor就是用来解决这一问题的核心思想.通过建立一颗监控树,来组织进程之间的关系,通过确定重启策略.子进程说明书等参数信息来确定 ...