牛客寒假6-G.区间或和
2024-08-25 20:12:22
链接:https://ac.nowcoder.com/acm/contest/332/G
题意:
求a|(a+1)|(a+2)|...|(b-1)|b。
思路:
求a-b的差的每一个二进制位
自己也看不懂。。。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL; int main()
{
LL a,b;
while(cin >> a >> b)
{
LL res = a;
LL x = 1;
while (a + x <= b)
{
res |= (x + a);
x <<= 1;
}
cout << (res|b) << endl;
} return 0;
}
最新文章
- 如何一步一步用DDD设计一个电商网站(六)—— 给购物车加点料,集成售价上下文
- Hive 的 map join
- Getting the first day in a week with T-SQL
- win7里边使用telnet命令提示telnet不是内部或外部命令
- mysql命令行登录指定编码
- Connection to DB
- ASIHTTPRequest详解
- “你什么意思”之基于RNN的语义槽填充(Pytorch实现)
- kernel pwn 入门环境搭建
- Python基础——6面向对象编程
- 记录初学者学习Hive时踩过的坑
- 【C++】atof()
- Pandas基本功能之选取索引和过滤
- BZOJ 3876: [Ahoi2014]支线剧情 带下界的费用流
- JAVA String.format 方法使用介绍<;转>;
- 9、Dockerfile语法
- LeetCode-Lowest Common Ancestor of a Binary Tre
- unity调用ios原生代码objective-c和回调
- tcp长连接分包方法
- 第二百二十三节,jQuery EasyUI,ComboBox(下拉列表框)组件