求出对于给到的 x x x和 s s s,存在多少个 y y y满足 x o r y = s x\ or \ y = s x or y=s。
首先考虑 y y y恒为 0 0 0的情况: x x x的某一位为 1 1 1, s s s的对应位为 0 0 0。
再考虑 y y y的情况种数:统计 x x x和 s s s同一位都为 1 1 1的位数,同时为 1 1 1,那么对于该位 y y y就有两种选择:然后 2 n 2^n 2n输出即可。
喜提WA…再读题,正整数。。。
考虑什么时候会出现 0 0 0这种及其特殊的数字: x x x的某一位为 0 0 0, s s s的对应位为 1 1 1,此时一定会出现 y y y取0的情况。单独挑出来 − 1 -1 −1即可。
#include
#define ll long long
#define int long long
using namespace std;
ll binpow(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1) res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
signed main(){
int x, s; cin >> x >> s;
int cnteq = 0, cntneq = 0;
bool flag = 1;
while(x || s){
int xbit = x & 1, sbit = s & 1;
if(xbit == 1 && sbit == 0) return cout = 1;
}
if(flag) cout
关注
打赏
- 回坑记之或许是退役赛季?
- [LCT刷题] P1501 [国家集训队]Tree II
- [LCT刷题] P2147 洞穴勘测
- 2022-2023 ICPC Brazil Subregional Programming Contest VP记录
- [线段树套单调栈] 2019-2020 ICPC Asia Hong Kong Regional Contest H.[Hold the Line]
- The 2021 ICPC Asia Nanjing Regional Contest E.Paimon Segment Tree 区间合并线段树/维护矩阵乘法
- CF580E - Kefa and Watch 线段树维护哈希
- HDU5869 Different GCD Subarray Query 离线查询/区间贡献
- 27.CF1004F Sonya and Bitwise OR 区间合并线段树
- 26.CF1000F One Occurrence