传送门

题目描述
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"的更多相关文章

  1. upc组队赛17 Bits Reverse【暴力枚举】

    Bits Reverse 题目链接 题目描述 Now given two integers x and y, you can reverse every consecutive three bits ...

  2. CCPC2018 桂林 G "Greatest Common Divisor"(数学)

    UPC备战省赛组队训练赛第十七场 with zyd,mxl G: Greatest Common Divisor 题目描述 There is an array of length n, contain ...

  3. [LeetCode] Reverse Bits 翻转位

    Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...

  4. Leetcode-190 Reverse Bits

    #190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432615 ...

  5. [leetcode] Reverse Bits

    Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...

  6. leetcode reverse bits python

    Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (re ...

  7. 【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 ...

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

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

  9. [LeetCode] 190. Reverse Bits 颠倒二进制位

    Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...

随机推荐

  1. IOS 后台挂起程序 当程序到后台后,继续完成Long-Running Task 任务

    我们知道,到我们程序从前台退到后台(安home)键后,将执行程序的委托方法. // 当应用程序掉到后台时,执行该方法 - (void)applicationDidEnterBackground:(UI ...

  2. 如何利用 Webshell 诊断 EDAS Serverless 应用

    本文主要介绍 Serverless 应用的网络环境以及 Serverless 应用容器内的环境,了解背景知识以及基本的运维知识后可以利用 Webshell 完成基本的运维需求. Webshell 简介 ...

  3. 生成主键ID,唯一键id,分布式ID生成器雪花算法代码实现

    工具类:  package com.ihrm.common.utils; import java.lang.management.ManagementFactory; import java.net. ...

  4. .Net Core,VUE,VS Code,Sql Sugar,Element UI学习笔记

    1..Net Core的目的是跨平台,并主要目标是作为服务端开发使用.从3.0开始,引入了Winfrom和WPF. 2..Net Core可以引用.Net Framework生成的dll和exe,不限 ...

  5. UVa 926【简单dp,递推】

    UVa 926 题意:给定N*N的街道图和起始点,有些街道不能走,问从起点到终点有多少种走法. 很基础的dp.递推,但是有两个地方需要注意,在标记当前点某个方向不能走时,也要同时标记对应方向上的对应点 ...

  6. POLARDB 2.0 重磅升级,分别支持Oracle与PostgreSQL

    点击订阅新品发布会! 新产品.新版本.新技术.新功能.价格调整,评论在下方,下期更新!关注更多内容,了解更多 最新发布 POLARDB 2.0 重磅升级 2019年6月19日15时,阿里云 POLAR ...

  7. @topcoder - SRM611D1L3@ ElephantDrinking

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定有一个 n*n 的平原,其中一些格子有些泉水.泉水每单位时间 ...

  8. vue element 中自定义传值

    一直以来都不知道如何传自定义的值,一直只会默认的,今天终于找到方法了. 比如这个上传图片的控件,想带当前的index过去,就这样写.其它的类似 :http-request="(file,fi ...

  9. Top 10 Free IT Certification Training Resources

    1. Cybrary Cybrary takes the open source concept and applies it to IT training. Many of the courses ...

  10. mysql数据库之存储引擎

    mysql存储引擎概述 什么是存储引擎?                                                               MYSQL中的数据用各不相同的技术 ...