CodeForces - 627A
CodeForces - 627A
https://vjudge.net/problem/326413/origin
a+b == (a&b)<<1 +(a^b);
然后是位运算,如果对于这一位置,异或值为1时,有两种可能,由乘法原理,答案<<1。如果s==x,就会出现一方全0,一方全1的情况,所以-2.
- #include<iostream>
- #include<cstdio>
- #include<queue>
- #include<algorithm>
- #include<cmath>
- #include<ctime>
- #include<set>
- #include<map>
- #include<stack>
- #include<cstring>
- #define inf 2147483647
- #define ls rt<<1
- #define rs rt<<1|1
- #define lson ls,nl,mid,l,r
- #define rson rs,mid+1,nr,l,r
- #define N 100010
- #define For(i,a,b) for(long long i=a;i<=b;i++)
- #define p(a) putchar(a)
- #define g() getchar()
- using namespace std;
- long long s,x,k,ans=,t;
- void in(long long &x){
- long long y=;
- char c=g();x=;
- while(c<''||c>''){
- if(c=='-')y=-;
- c=g();
- }
- while(c<=''&&c>=''){
- x=(x<<)+(x<<)+c-'';c=g();
- }
- x*=y;
- }
- void o(long long x){
- if(x<){
- p('-');
- x=-x;
- }
- if(x>)o(x/);
- p(x%+'');
- }
- int main(){
- in(s);in(x);
- t=x;
- k=(s-x)>>;
- if(s<x||(s-x)%==){
- o();
- return ;
- }
- while(x>){
- if(x&)
- ans<<=;
- if((x&)&&(k&)){
- ans=;
- break;
- }
- k>>=;
- x>>=;
- }
- if(s==t)
- ans-=;
- o(ans);
- return ;
- }
CodeForces - 627A的更多相关文章
- Codeforces 627A XOR Equation(思路)
题目大概说两个正整数a.b,已知s=a+b以及x=a xor b的值,问有几种a.b这样的数对. 我知道异或相当于无进位的加法,s-x就是其各个位置的进位,比如s-x=1010,那就表示a和b的第1位 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- java_JDK8中新增的时间API
java.time 包含值对象的基础包 java.time.chrono 提供对不同的日历系统的访问 java.time.format 格式化和解析时间的日期 java.time.temporal 包 ...
- sql 根据列名查所属表名
比如 有一个jueseID字段,想知道这个字段是哪个表里的. 第一步: select * from syscolumns where name = 'jueseID' 第二步: select * fr ...
- go string和[ ]byte
https://www.cnblogs.com/zhangboyu/p/7623712.html
- Apache下更改.htaccess文件名称
有时候我们需要更改.htaccess的名称以解决一些问题 比如:Eclipse下是不显示点开头的文件的 所以我们可以使用 Apache的AccessFileName来更改此配置文件的名称 Acces ...
- ThreadLocal简析
简介 ThreadLocal在Java多线程开发中常见的一个类,在面试中也经见的问题,比如ThreadLocal的作用是什么,ThreadLocal的实现原理是什么等等.ThreadLocal是jav ...
- python mysql数据库中 json的存储
首先数据库里的字段类型需要设置为json: 存储这个json时需要把这个json变为字符串,而且是最外层为单引号,内部字符串为双引号!如图: 所以python脚本中这个字段的字符串应该这样写: 得出 ...
- We'll be fine.
可怜的人心中都有一种信念,那就是 明天会更好. Everything will be fine. 我拥见风来,嗅见花开,是避不掉的厉寒,是止不住的徘徊.
- js获取网页屏高 屏宽
<SCRIPT LANGUAGE="JavaScript"> <!-- //document.body.scrollTop 滚动条的上端距离 //document ...
- Redis深度历险——核心原理与应用实践
高可用架构」的各位老铁们,你们好!你是否还记得上个月发布的文章中,有两篇深入讲解Redis的文章,分别是和,广大粉丝读者们对这两篇文章整体评价颇高.而我就是这两篇文章的原创作者「老钱」(钱文品),我是 ...
- windows 可执行文件分析
windows可执行文件是什么? 是具有PE文件格特性的文件,例如:.exe.dll.ocx等文件. 注:(这里只是让大家能明了一些,其实,可执行与否,和后缀没有什么关系,后缀只是windows方便管 ...