HDU 5661 Claris and XOR(异或,贪心)
来源:互联网 发布:电脑怎样连接手机网络 编辑:程序博客网 时间:2024/06/01 13:36
题目链接:
HDU 5661 Claris and XOR
题意:
给定区间
数据范围:
分析:
从后往前贪心。假设当前考虑到第
例如对于
但是我们还要同时考虑
#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>using namespace std;typedef long long ll;int T;ll a, b, c, d;bool check(ll x, ll y, int pos){ ll extra = ((ll)1 << pos) - 1; ll xx = x + extra, yy = y + extra; if (x > b || xx < a) return false; if (y > d || yy < c) return false; return true;}int main(){ scanf("%d", &T); while (T--) { scanf("%lld%lld%lld%lld", &a, &b, &c, &d); ll x = 0, y = 0; for (int i = 62; i >= 0; --i) { ll delt = (ll)1 << i; if (check(x + delt, y, i)) x += delt; else if (check(x, y + delt, i)) y += delt; else if (check(x + delt, y + delt, i)) x += delt, y += delt; } printf("%lld\n", x ^ y); } return 0;}
0 0
- HDU 5661 Claris and XOR(异或,贪心)
- HDU 5661 Claris and XOR(按位异或贪心)
- HDU-5661 Claris and XOR (贪心)
- HDU 5661 Claris and XOR(贪心)
- HDU 5661 Claris and XOR
- HDU-5661-Claris and XOR
- HDU 5661 Claris and XOR
- Hdu 5661 Claris and XOR
- HDU 5661 Claris and XOR
- 【Hdu 5661】 Claris and XOR 位运算+贪心
- BestCoder Round #79 1002/hdu 5661 Claris and XOR 贪心
- HDU 5661/BC 79B Claris and XOR
- HDU5661---Claris and XOR
- Claris and XOR
- bestcoder 79 Claris and XOR
- BC之Claris and XOR
- HDU 3949 XOR 异或
- BestCoder Round #79 (div.1) Claris and XOR 题解。。。
- c++计时函数
- Python中的除法
- 与Hadoop相比,怎么看待spark?
- 初学HTML(1)--helloworld初体验
- HDU5804 BestCoder Round 86A 【Price List】
- HDU 5661 Claris and XOR(异或,贪心)
- c++ g++一些区别
- JAVA增删改查XML文件
- 数据结构学习笔记10——区分叶结点与分支结点的二叉树实现方案二
- Linux内核面试问题汇总
- Compile old non-existing UCA packages (by quqi99)
- 阿里中间件——消息中间件Notify和MetaQ
- Android的volley请
- poj 2442 Sequence