CodeForces 635C XOR Equation 数学 公式
2016-08-15 20:47
363 查看
#include<stdio.h> #include<string> #include<cstring> #include<queue> #include<algorithm> #include<functional> #include<vector> #include<iomanip> #include<math.h> #include<iostream> #include<sstream> #include<set> #include<climits> #include<map> #include<bitset> using namespace std; int main() { cin.sync_with_stdio(false); long long s,x,Ans=0; cin>>s>>x; //a + b = (a Xor b) + (a & b) * 2 ; //a + b = s ; a Xor b = x ; //s - x = (a & b) * 2; if ((s-x>=0)&&(s-x)%2==0) { long long Andsum = (s - x) >> 1; int cnt = 0; bool flag = true; if(s==x) Ans = -2; while(x) { if(x&1) { cnt++; if(Andsum&1) flag = false; } if (!flag) break; x>>=1; Andsum>>=1; } if (!flag) Ans=0; else Ans+=(1LL<<cnt); } cout<<Ans; return 0; }
相关文章推荐
- Codeforces 513C Second price auction 数学公式求期望
- Codeforces 534C Polycarpus' Dice(数学,公式推导)
- Codeforces 615D Multipliers(数学推公式)
- codeforces Buttons 数学公式构建
- Codeforces 839D Winter is here【容斥原理+数学公式】
- CodeForces 630Q Pyramids(数学公式)
- Codeforces 758C Unfair Poll 数学推导,公式
- CodeForces 659 D. Bicycle Race(计算几何 + 数学公式)
- codeforces 650 C. Watchmen(数学公式)
- codeforces 616E Sum of Remainders(数学公式转化 较难)
- codeforces 616E Sum of Remainders 数学公式转化
- 数学公式和符号的念法
- codeforces 337C Quiz(快速幂+推公式+贪心)
- Codeforces 37D Lesson Timetable - 组合数学 - 动态规划
- CodeForces 567C. Geometric Progression(map 数学啊)
- 数学定义与公式
- Markdown中插入数学公式的方法
- 在博客园中写数学公式
- 【CodeForces】670A - Holidays(数学)
- Codeforces 888D - Almost Identity Permutations 【数学模拟】