传送门

题目描述
Now given two integers x and y, you can reverse every consecutive three bits in arbitrary number’s binary form (any leading zero can be taken into account) using one coin. Reversing (1,2,3) means changing it into (3,2,1).
Could you please find a way that minimize number of coins so that x = y? If you can, just output the minimum coins you need to use.输入
The first line of input file contains only one integer T (1≤T≤10000) indicating number of test cases.
Then there are T lines followed, with each line representing one test case.
For each case, there are two integers x, y (0≤x,y≤1018) described above.输出
Please output T lines exactly.
For each line, output Case d: (d represents the order of the test case) first. Then output the answer in the same line. If there is no way for that, print -1 instead.

题意描述

样例输入
3
0 3
3 6
6 9样例输出
Case 1: -1
Case 2: 1
Case 3: 2

样例输入输出

题意:

  给你两个数 x,y,定义一个操作,可以反转连续的三个位置(转化成二进制后的连续三个位置);

  问,最少需要多少操作,可以使得 x == y;

  如果不能,输出 -1;

思路:

  这题卡了一会,如何快速交换二进制的两个位的值呢?

  答案:异或大法好;

  假设 x = (100)

  定义 t1 = x&1 , t3 = x>>2&1 ;

  x ^= (t1^t3);

  x ^= (t1^t3)<<2;

本来就不是难题,还是,数据不太给力????????

为啥看了几篇2018CCPC桂林游记,他们的这个题,都wa了好多发呢????

总有种不太靠谱的感觉,可,也找不出错误样例了!!!!

 

转载于:https://www.cnblogs.com/violet-acmer/p/10803124.html

CCPC2018 桂林 D Bits Reverse相关推荐

  1. [LeetCode] Number of 1 Bits Reverse Integer - 整数问题系列

    目录: 1.Number of 1 Bits  - 计算二进制1的个数 [与运算] 2.Contains Duplicate - 是否存在重复数字 [遍历] 3.Reverse Integer - 翻 ...

  2. LeetCode 190. Reverse Bits (算32次即可)

    题目: Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 ...

  3. java reverse_Java Integer类reverse()方法与示例

    java reverse 整数类reverse()方法 (Integer class reverse() method) reverse() method is available in java.l ...

  4. 2018CCPC桂林站题解(D G H J L)

    题目链接:http://codeforces.com/gym/102823 问题 D: Bits Reverse 时间限制: 1 Sec  内存限制: 128 MB 提交: 167  解决: 127 ...

  5. ffmpeg使用总结

    2019独角兽企业重金招聘Python工程师标准>>> 下载安装 下载地址 提供了可执行文件和动态库,纯命令行使用Architecture版本. 查看当前dshow可用的录像设备和录 ...

  6. [笔试题目] 美团2015年9月后端开发工程师笔试题

    由于题目是我通过草稿回顾,可能表述不清,但是内容大致一样.希望该博客内容对你有所帮助,题目所有权归美团公司所有,我只是想分享给大家学习,还望贵公司海涵~ 面试职位 应聘职位:后端开发工程师 岗位描述: ...

  7. LeetCode 简单算法题

    使用Nodejs 抓取的LeetCode 简单算法题  一步一步来,先攻破所有简单的题目,有些题目不适合使用JS解决,请自行斟酌 Letcode 简单题汇总 104. Maximum Depth of ...

  8. 2020双周训练训练日志

    第 3 次双周训练 VP A - 6789 签到题,按照题意模拟就行了,由于 lincong 将题目中的"中心对称"看成了"轴对称",导致 WA 了三发还不知道 ...

  9. 感谢十二年的陪伴——分享回归,不忘初心(Eastmount博客总结及未来规划)

    曾记否,2021年4月28日,为了更好地从事科研和学习,当时给所有读者群发了我在CSDN唯一的私信,感谢大家十年的陪伴,短暂消失,不负青春.当时也收到了很多博友的鼓励与祝福,感恩. 是啊!很难想象读博 ...

最新文章

  1. docker配置国内镜像源
  2. dos2unix批量转换的脚本
  3. MySQL—事务隔离级别
  4. CSU - 2059 Water Problem(Z线分割平面)
  5. 51Nod 1439 - 互质对(容斥+莫比乌斯函数)
  6. Nagios搭建及问题详解(一)
  7. 网外(Internet)访问代理服务器内部的实现方法
  8. 智慧城市大数据运营中心,发挥大数据价值
  9. 太经典了,不转不行淘宝上面的对话
  10. 计算机二级C语言辅导考试买啥书,在大学想考计算机二级,请问自学的话需要买什么辅导书,要买好几本是吗?...
  11. k线必涨的20种形态图
  12. 谈谈UG二次开发程序入口
  13. 如何往linux虚拟机传文件,Windows中虚拟机Linux传输文件的两个简单的方法
  14. 分享Silverlight/WPF/Windows Phone一周学习导读
  15. Java给字符串数组动态赋值
  16. poj Best Cow Line
  17. MSDN上关于WinDbg的手册
  18. 软件测试的软件资源,软件测试都会都用到哪些工具?
  19. python北京奥运会_Python分析奥运会120年历史,谁才是奥运历史的王者?
  20. 对数据集使用GLCM(灰度共生矩阵)进行纹理提取

热门文章

  1. 浮云绘图编辑器之文字、图片基础图元操作及源码,用于文本描述及拓扑图、平面布局图开发
  2. 图文详解在Windows系统中安装JDK
  3. 老人与海好词100英文带翻译_The_Old_Man_and_The_Sea_老人与海_中英文对照版_(good)
  4. 【LeetCode】871. Minimum Number of Refueling Stops 解题报告(Python)
  5. sql进行批量更新或者一条sql写出批量更新的语句
  6. ac1900 linksys 恢复_AC1900路由器怎么恢复出厂设置?
  7. Gulp教程(3)-与远程版本库协作
  8. 【GPU加速】安装pycuda异常:Failed to build pycuda ERROR: Could not build wheels for pycuda, which is requir
  9. 【HDL系列】除法器(3)——基2 SRT算法
  10. 内容营销的思维方式 阿胜说