题意:给定两个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. 每个极客都应该知道的Linux技巧

    每个极客都应该知道的Linux技巧 2014/03/07 | 分类: IT技术 | 0 条评论 | 标签: LINUX 分享到:18 本文由 伯乐在线 - 欣仔 翻译自 TuxRadar Linux. ...

  2. MapView的用法

    一.MapView 1.显示用户的位置点(用蓝色圆点标记) mapView.showsUserLocation = YES; 2.代理方法 1> 当定位到用户的位置就会调用 - (void)ma ...

  3. (C#基础) byte[] 之初始化, 赋值,转换。

    byte[] 之初始化赋值 用for loop 赋值当然是最基本的方法,不过在C#里面还有其他的便捷方法. 1. 创建一个长度为10的byte数组,并且其中每个byte的值为0. byte[] myB ...

  4. 关于Java接口

    1 接口的本质 (1)一组有规则的集合: (2)一定视角上的同类事物的抽象:同类事物的概念是相对的 2 接口与抽象类的区别 (1)java不支持类的多继承,但可以实现多个接口: (2)使用动机:抽象类 ...

  5. 收集些日本的VPS

    http://www.serverqueen.jp/service/vps.html http://www.seeds.ne.jp http://dream.jp/vps/ http://fc2-vp ...

  6. 【转】Android 服务器之SFTP服务器上传下载功能

    原文网址:http://blog.csdn.net/tanghua0809/article/details/47056327 本文主要是讲解Android服务器之SFTP服务器的上传下载功能,也是对之 ...

  7. jquery图片裁切+PHP文件上传

    下载地址:download.csdn.net/source/2745353

  8. Cocos2d-android (01) 创建一个简单的cocos2d应用程序

    下载Cocos2d-android的源代码:cocos2d-android-1 git@github.com:ZhouWeikuan/cocos2d.git 将项目导入到eclipse中.运行实例: ...

  9. 静态成员变量.xml

    pre{ line-height:1; color:#1e1e1e; background-color:#f0f0f0; font-size:16px;}.sysFunc{color:#627cf6; ...

  10. eclipse quick diff功能

    Eclipse文本编辑器和Java编辑器都提供了quick diff功能.这就使得你可以快速地识别出当前所编辑文件版本和该文件的参考版本之间的不同. 如果编辑器的quick diff功能没有启用,可以 ...