CodeForces - 627A
https://vjudge.net/problem/326413/origin
a+b == (a&b)<<1 +(a^b);
然后是位运算,如果对于这一位置,异或值为1时,有两种可能,由乘法原理,答案<<1。如果s==x,就会出现一方全0,一方全1的情况,所以-2.

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<queue>
  4. #include<algorithm>
  5. #include<cmath>
  6. #include<ctime>
  7. #include<set>
  8. #include<map>
  9. #include<stack>
  10. #include<cstring>
  11. #define inf 2147483647
  12. #define ls rt<<1
  13. #define rs rt<<1|1
  14. #define lson ls,nl,mid,l,r
  15. #define rson rs,mid+1,nr,l,r
  16. #define N 100010
  17. #define For(i,a,b) for(long long i=a;i<=b;i++)
  18. #define p(a) putchar(a)
  19. #define g() getchar()
  20.  
  21. using namespace std;
  22. long long s,x,k,ans=,t;
  23. void in(long long &x){
  24. long long y=;
  25. char c=g();x=;
  26. while(c<''||c>''){
  27. if(c=='-')y=-;
  28. c=g();
  29. }
  30. while(c<=''&&c>=''){
  31. x=(x<<)+(x<<)+c-'';c=g();
  32. }
  33. x*=y;
  34. }
  35. void o(long long x){
  36. if(x<){
  37. p('-');
  38. x=-x;
  39. }
  40. if(x>)o(x/);
  41. p(x%+'');
  42. }
  43. int main(){
  44. in(s);in(x);
  45. t=x;
  46. k=(s-x)>>;
  47. if(s<x||(s-x)%==){
  48. o();
  49. return ;
  50. }
  51. while(x>){
  52. if(x&)
  53. ans<<=;
  54. if((x&)&&(k&)){
  55. ans=;
  56. break;
  57. }
  58. k>>=;
  59. x>>=;
  60. }
  61. if(s==t)
  62. ans-=;
  63. o(ans);
  64. return ;
  65. }

CodeForces - 627A的更多相关文章

  1. Codeforces 627A XOR Equation(思路)

    题目大概说两个正整数a.b,已知s=a+b以及x=a xor b的值,问有几种a.b这样的数对. 我知道异或相当于无进位的加法,s-x就是其各个位置的进位,比如s-x=1010,那就表示a和b的第1位 ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. java_JDK8中新增的时间API

    java.time 包含值对象的基础包 java.time.chrono 提供对不同的日历系统的访问 java.time.format 格式化和解析时间的日期 java.time.temporal 包 ...

  2. sql 根据列名查所属表名

    比如 有一个jueseID字段,想知道这个字段是哪个表里的. 第一步: select * from syscolumns where name = 'jueseID' 第二步: select * fr ...

  3. go string和[ ]byte

    https://www.cnblogs.com/zhangboyu/p/7623712.html

  4. Apache下更改.htaccess文件名称

    有时候我们需要更改.htaccess的名称以解决一些问题 比如:Eclipse下是不显示点开头的文件的 所以我们可以使用  Apache的AccessFileName来更改此配置文件的名称 Acces ...

  5. ThreadLocal简析

    简介 ThreadLocal在Java多线程开发中常见的一个类,在面试中也经见的问题,比如ThreadLocal的作用是什么,ThreadLocal的实现原理是什么等等.ThreadLocal是jav ...

  6. python mysql数据库中 json的存储

    首先数据库里的字段类型需要设置为json: 存储这个json时需要把这个json变为字符串,而且是最外层为单引号,内部字符串为双引号!如图:  所以python脚本中这个字段的字符串应该这样写: 得出 ...

  7. We'll be fine.

    可怜的人心中都有一种信念,那就是 明天会更好. Everything will be fine. 我拥见风来,嗅见花开,是避不掉的厉寒,是止不住的徘徊.

  8. js获取网页屏高 屏宽

    <SCRIPT LANGUAGE="JavaScript"> <!-- //document.body.scrollTop 滚动条的上端距离 //document ...

  9. Redis深度历险——核心原理与应用实践

    高可用架构」的各位老铁们,你们好!你是否还记得上个月发布的文章中,有两篇深入讲解Redis的文章,分别是和,广大粉丝读者们对这两篇文章整体评价颇高.而我就是这两篇文章的原创作者「老钱」(钱文品),我是 ...

  10. windows 可执行文件分析

    windows可执行文件是什么? 是具有PE文件格特性的文件,例如:.exe.dll.ocx等文件. 注:(这里只是让大家能明了一些,其实,可执行与否,和后缀没有什么关系,后缀只是windows方便管 ...