http://acm.hdu.edu.cn/showproblem.php?pid=4768

貌似非常多人是用的二分

可是更好的做法貌似还是异或

对于第k个人。假设他接到偶数个传单。那么异或的结果还是0

就是说op记录全部收到传单的人次的总的异或值。那么由于仅仅有一个是收到奇数次。所以异或值就是他的编号,至于收到几次,在O(n)能够计算

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std; #define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const double pi = acos(-1.0);
const int INF = 100000000;
const int MAXN = 20010 +20; int a[MAXN],b[MAXN],c[MAXN],n; int main()
{
while(~scanf("%d",&n)){
int op=0,cnt=0;
for(int i=0;i<n;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
for(int j=a[i];j<=b[i];j+=c[i])
op^=j;
}
for(int i=0;i<n;i++){
if(op>=a[i] && op <=b[i] && (op-a[i])%c[i]==0)cnt++;
}
if(cnt%2==0)printf("DC Qiang is unhappy.\n");
else printf("%d %d\n",op,cnt);
}
return 0;
}

hdu 4768 异或运算的更多相关文章

  1. HDU.2095(异或运算)

    find your present (2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...

  2. HDU 1287 破译密码 异或运算

    http://acm.hdu.edu.cn/showproblem.php?pid=1287 题目: 有个叫"猪头帮"的国家,采用一种简单的文法加密,他们所用的语言里面只有大写字母 ...

  3. HDU 5968 异或密码

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  4. 网络误区:不用中间变量交换2个变量的value,最高效的是异或运算.

    本文记录了不使用中间变量交换2个变量的value,很多的网络留言说是直接异或运算就可以了,而且效率很高,是真的吗? 这里简单的说一下我的环境:Win7 32位,Qt creator 5.4.1 编译器 ...

  5. C、C++、Java异或运算交换变量变量值的区别

    今天看到一位大神的博客,深受感触.决定也发一篇博客,证明一下我还活着. 于是我翻看以前学习时做的一些笔记,整理了一下,得到了一个关于异或运算交换变量变量值的笔记. 首先来看下面三组表达式,看起来他们都 ...

  6. HDOJ 1287 破译密码(异或运算)

    Problem Description 有个叫"猪头帮"的国家,采用一种简单的文法加密,他们所用的语言里面只有大写字母,没有其他任何字符:现在还知道他们加密的方法是:只用一个大写字 ...

  7. hdu2095 像水题的不错题 异或运算

    异或运算的基础有点忘记了 先介绍一下..2个数异或 就是对于每一个二进制位进行位运算 具有2个特殊的性质 1.一个数异或本身恒等于0,如5^5恒等于0: 2.一个数异或0恒等于本身,如5^0恒等于5. ...

  8. bis和bic命令实现或和异或运算

    从20世纪70年代末到80年代末,Digital Equipment的VAX计算机是一种非常流行的机型.它没有布尔运算AND和OR指令,只有bis(位设置)和bic(位清除)这两种指令.两种指令的输入 ...

  9. 二进制按位与(&) 按位或(|)  异或运算(^)

    1.参加运算的两个数据,按照二进制进行按位与的运算. 运算规则:0&0=0;   0&1=0;    1&0=0;     1&1=1; 即:两位同时为“1”,结果才为 ...

随机推荐

  1. Xml的读取

    using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebAp ...

  2. Android RecyclerView使用 及 滑动时加载图片优化方案

    1.控制线程数量 + 数据分页加载2.重写onScrollStateChanged方法 这个我们后面再谈,下面先来看看RecyclerView控件的使用及我们为什么选择使用它 RecyclerView ...

  3. Failed to resolve com.android.support:support-annotations 26.0.1

    所有当前版本的Google库都存放在 Google的Maven repository (maven.google.com),不在旧的offline-capable support repositori ...

  4. PHP 之获取Windows下CPU、内存的使用率

    <?php /** * Created by PhpStorm. * User: 25754 * Date: 2019/5/4 * Time: 13:42 */ class SystemInfo ...

  5. jenkins执行python脚本

    参考: https://blog.csdn.net/qq_39247153/article/details/81003244 https://blog.csdn.net/huashao0602/art ...

  6. java 异常报错总结

    1.java.lang.ArithmeticException:这是算数异常 比如分母位0 2. java.lang.ArrayIndexOutOfBoundsException:数组下标越界异常 3 ...

  7. MVC Ajax调用Action时-OnActionExecuting RedirectResult 无法跳转的处理办法

    public class BaseController : Controller { protected override void OnActionExecuting(ActionExecuting ...

  8. openstack——neutron网络服务

    一.neutron 介绍:   Neutron 概述 传统的网络管理方式很大程度上依赖于管理员手工配置和维护各种网络硬件设备:而云环境下的网络已经变得非常复杂,特别是在多租户场景里,用户随时都可能需要 ...

  9. chrony配置介绍

    rhel7 文档https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Adminis ...

  10. HDU3336Count the string

    HDU3336Count the string Problem Description It is well known that AekdyCoin is good at string proble ...