CCPC2018 桂林 D "Bits Reverse"
题目描述
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 (,,) means changing it into (,,).
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 (≤T≤) 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 (≤x,y≤) 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 - instead.
题意描述
样例输入 样例输出
Case : -
Case :
Case :
样例输入输出
题意:
给你两个数 x,y,定义一个操作,可以反转连续的三个位置(转化成二进制后的连续三个位置);
问,最少需要多少操作,可以使得 x == y;
如果不能,输出 -1;
思路:
这题卡了一会,如何快速交换二进制的两个位的值呢?
答案:异或大法好;
假设 x = (100)
定义 t1 = x&1 , t3 = x>>2&1 ;
x ^= (t1^t3);
x ^= (t1^t3)<<2;
本来就不是难题,还是,数据不太给力????????
为啥看了几篇2018CCPC桂林游记,他们的这个题,都wa了好多发呢????
总有种不太靠谱的感觉,可,也找不出错误样例了!!!!
CCPC2018 桂林 D "Bits Reverse"的更多相关文章
- upc组队赛17 Bits Reverse【暴力枚举】
Bits Reverse 题目链接 题目描述 Now given two integers x and y, you can reverse every consecutive three bits ...
- CCPC2018 桂林 G "Greatest Common Divisor"(数学)
UPC备战省赛组队训练赛第十七场 with zyd,mxl G: Greatest Common Divisor 题目描述 There is an array of length n, contain ...
- [LeetCode] Reverse Bits 翻转位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Leetcode-190 Reverse Bits
#190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432615 ...
- [leetcode] Reverse Bits
Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...
- leetcode reverse bits python
Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...
- 【LeetCode】190 & 191 - Reverse Bits & Number of 1 Bits
190 - Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432615 ...
- LeetCode 190. Reverse Bits (算32次即可)
题目: 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432 ...
- [LeetCode] 190. Reverse Bits 颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...
随机推荐
- js 全角与半角互转
///全角空格为12288,半角空格为32 ///其他字符半角(33-126)与全角(65281-65374)的对应关系是:均相差65248 //半角转换为全角函数 function ...
- 仿Google Nexus菜单样式
在线演示 本地下载
- oracle dbms_repcat_admin能带来什么安全隐患
如果一个用户能执行dbms_repcat_admin包,将获得极大的系统权限. 以下情况可能获得该包的执行权限: 1.在sys下grant execute on dbms_repcat_admin t ...
- 开通了第一个博客,mark一下!
今日上网查询了不同的博客,包括csdn.掘金等,最终决定选择博客园.打算待前端学完后,自己建立一个博客,这段时间内先用博客园记录学习过程.经常总结.更新,相信坚持学习一定可以找到好工作!
- 【转载】Ubuntu终端常用的快捷键
Ubuntu中的许多操作在终端(Terminal)中十分的快捷,记住一些快捷键的操作更得心应手.在Ubuntu中打开终端的快捷键是Ctrl+Alt+T.其他的一些常用的快捷键如下: 快捷键 功能 Ta ...
- vue-quill-editor 封装成组件;图片文件流上传;同一页面多个编辑器样式异常解决办法
使用方法: 引入并注册组件,然后直接使用: @getcode是同步获取编辑器内容的::contentDefault是编辑器的默认内容: 注意:如果同一个页面多个编辑器,参数id不能相同,否则只有第一个 ...
- @loj - 2480@ 「CEOI2017」One-Way Streets
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一张 n 个点 m 条边的无向图,现在想要把这张图定向. 有 ...
- re模块下的常用方法
一 : re模块的查找 findall 优先级查找 返回列表 找所有的匹配项(从大段的内容中找匹配到的项目) import re str = "qwer asdf zxcv qwer ...
- oracle中的闪回
项目中运用: 首先说明:闪回方法有一个前提,就是需要尽早的发现问题,果断的采取行动.若误操作的记录已经在UNDO表空间中被清除,则此方法就不可行了,需要另寻他法. 例如: SELECT * FROM ...
- 求eclipse中的java build path 详解
我也找了一下资料,但未找到相关的正式说明,我只能凭经验告诉你. 1,Source是指资源的路径.例如在没有包含res之前,资源是放在与src同级位置,或者通过/res/*.*来操作的.2,Projec ...