LuckyXor
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

TC

Description

A lucky number is a positive integer consisting of only the digits 4 and 7.
Given an int a, return an int b strictly greater than a, such that a XOR b is a lucky number. (See Notes for the definition of XOR.) The number b should be in the range 1 to 100, inclusive. If such a number does not exist, return -1. If there are multiple such b, you may return any of them.

XOR is the bitwise exclusive-or operation. To compute the value of P XOR Q, we first write P and Q in binary. Then, each bit of the result is computed by applying XOR to the corresponding bits of the two numbers, using the rules 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, and 1 XOR 1 = 0.
For example, let's compute 21 XOR 6. In binary these two numbers are 10101 and 00110, hence their XOR is 10011 in binary, which is 19 in decimal.
You can read more about the XOR operation here: https://en.wikipedia.org/wiki/Exclusive_or

Input

a is between 1 and 100, inclusive.

Output

int construct(int a)

Sample Input

4

Sample Output

40

HINT

题意

让你找到一个b,使得a^b是幸运数

幸运数指的是只含有4或者7的数

题解

数据范围只有100,所以直接暴力就好了

代码:

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;class LuckyXor{
public:int check(int x){while(x){int X=x%10;if(X==4||X==7)x/=10;elsereturn 0;}return 1;}int construct(int a){int ans=-1;for(int i=a+1;i<=100;i++){int X=(a^i);if(check(X)==1){ans=i;break;}}return ans;}
};

TC SRM 665 DIV2 A LuckyXor 暴力相关推荐

  1. TC SRM 665 DIV2 B LuckyCycle 暴力

    LuckyCycle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.a ...

  2. TC SRM 562 div2 B 题

    题意: 给你一个矩形的画布,此画布由'B'和'.'组成,画T次每次画的时候他的左上角的起始点是确定的几位(1,1),(2,2),(3,3)......(T,T); 在画的过程中可能会出现相互覆盖求画完 ...

  3. TC SRM 593 DIV2 1000

    很棒的DP,不过没想出,看题解了..思维很重要. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstrin ...

  4. TC SRM 553 DIV2

    转载请注明出处,谢谢http://blog.csdn.net/acm_cxlove/article/details/7854526       by---cxlove 赤裸裸的又在送rate. 250 ...

  5. TC SRM 655 Div1 Level 3 题解

    TC SRM 655 Div1 Level 3 题解 题目传送门 dp+几何 首先可以发现凸包是顺时针排列的一些线段构成的.我们可以预处理每一个蓝点是否都在一个线段 r [ i ] → r [ j ] ...

  6. TC(SRM)和CF入门教程for ACMer[转载]

    一.TC基本介绍TC的网址www.topcoder.com/tc,我们一般提到TC的时候是特指其中的Single Round Match(SRM).SRM的规则总结起来就是一句话:75分钟做完3道难度 ...

  7. TC(SRM)和CF入门教程for ACMer

    一.TC基本介绍 TC的网址www.topcoder.com/tc,我们一般提到TC的时候是特指其中的Single Round Match(SRM). SRM的规则总结起来就是一句话:75分钟做完3道 ...

  8. Topcoder Srm 671 Div2 1000 BearDestroysDiv2

    \(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...

  9. topcpder SRM 664 div2 A,B,C BearCheats , BearPlays equalPiles , BearSorts (映射)

    A题,熊孩子测视力,水题,题意就是判断一下两个数对应位不相同的数字有多少个. #include<bits/stdc++.h>using namespace std;class BearCh ...

  10. SRM 543 Div2

    决定以后多做一些TC,即使做不了比赛,也要多做一些TC上的题,顺便写一些结题报告什么的.不过像我这种在Div2混的弱菜,也写不出什么高质量的结题报告,而且1000pt的题,我基本都不用看了,尽量把25 ...

最新文章

  1. web前端培训分享:面向对象中类和对象的定义是什么?
  2. Oracle创建用户设置权限
  3. 关于C#中的类访问修饰符
  4. python 重写__repr__与__str__函数
  5. java sox语音_Sox语音转换的相关知识
  6. Kubernetes 的自动伸缩你用对了吗?
  7. 分布式Tensorflow入门Demo
  8. SQLite事务与自增深度分析
  9. python为什么用class_python为什么会有@classmethod?
  10. java ssm框架做增删改查,使用SSM框架组合实现增删改查的功能
  11. mysql数据库数据表的指令_mysql数据库和表操作命令
  12. QGIS快速提取建筑和道路矢量
  13. RMAN恢复Oracle数据库到不同的服务器
  14. Win10企业版系统安装 NET Framework 4.8的时候提示错误信息
  15. 动态口令,动态密码生成(OTP)
  16. 免费云服务器+免费虚拟主机推荐
  17. Porotech 展示突破性的 MicroLED 显示器
  18. 保时捷Taycan的800V电气架构赏析
  19. 一篇让小白彻底搞懂性能调优!
  20. 首个超越经典算法的寻找MIS近似解的量子算法诞生

热门文章

  1. Android系统简介(中):系统架构
  2. 兼容性所有浏览器的透明CSS设置
  3. 设计模式学习--迭代器模式(Iterator Pattern)和组合模式(Composite Pattern)
  4. Sinevibes Plugins Bundle for Mac(Sinevibes合成器合集)
  5. iOS底层探索之KVO(四)—自定义KVO
  6. iOS 面试题分析(二)
  7. nfs文件共享服务器搭建详解
  8. 可扩展的通用异常检测系统 EGADS
  9. 给大家带来点福利 整理了一些学习网站,问答网站,和IT咨询网站
  10. 了解mysql的undo log