627 A codeforces
来源:互联网 发布:图书馆数据库设计报告 编辑:程序博客网 时间:2024/06/09 18:32
给出 a+b 的值 , a^b 的值
求 a b ,满足的条件有多少种
a+b = a^b +(a&b)*2
证明:
a : 1 0 0 1 1
b: 1 0 1 0
a+b: 1 1 1 0 1
a^b: 1 1 0 0 1
由于 a^b 会使 的其所在位变为0 ,所以减少了 1<<位数,即 (a&b *2
#include<bits/stdc++.h>using namespace std;int main(){ __int64 a,b; scanf("%I64d%I64d",&a,&b); __int64 ans = 1; int gf = 0; if(a==b) gf = -2; if( a - b>=0&&(a-b)%2==0) { __int64 x= (a-b)/2; int cot = 0; int flag= 1; while(b) { if(b%2) { if(x%2) { flag = 0; } ans = ans*2; } if(!flag) break; x=x/2; b = b/2; } if(!flag) { cout<<"0"<<endl; return 0; } printf("%I64d\n",ans+gf); } else { printf("0\n"); }}
0 0
- 627 A codeforces
- CodeForces 627A XOR Equation
- Codeforces 627A XOR Equation
- CodeForces-a
- Codeforces 903A A
- Codeforces 627A XOR Equation 【数学】
- ♥codeforces 627A-XOR Equation【数学】
- CodeForces 18A A - Triangle
- CodeForces 133A A. HQ9+
- codeforces 651A A. Joysticks
- 【Codeforces 597A】A. Divisibility
- 【 Codeforces 615A】A. Bulbs
- A. Divisibility CodeForces 597A
- codeforces 417A A. Elimination
- CodeForces 534A A. Exam
- codeforces#98 a
- codeforces#99 a
- codeforces 105 div2 A
- 链表的部分翻转
- android布局属性详解
- 刷新CListCtrl中的Item
- 消息队列之JMS和AMQP对比
- 我不知道的
- 627 A codeforces
- android自定义通用下拉刷新
- java int short long float double 大整理
- HBase分布式安装
- C/C++ 图像二进制存储与读取
- 51nod1613翻硬币规律!
- 关于xml类型的背景文件的编写
- Java的IO流—思维导图
- 【POJ2778】 DNA Sequence AC自动机+矩阵快速幂