Showstopper
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2236   Accepted: 662

Description

Data-mining huge data sets can be a painful and long lasting process if we are not aware of tiny patterns existing within those data sets.

One reputable company has recently discovered a tiny bug in their hardware video processing solution and they are trying to create software workaround. To achieve maximum performance they use their chips in pairs and all data objects in memory should have even number of references. Under certain circumstances this rule became violated and exactly one data object is referred by odd number of references. They are ready to launch product and this is the only showstopper they have. They need YOU to help them resolve this critical issue in most efficient way.

Can you help them?

Input

Input file consists from multiple data sets separated by one or more empty lines.

Each data set represents a sequence of 32-bit (positive) integers (references) which are stored in compressed way.

Each line of input set consists from three single space separated 32-bit (positive) integers X Y Z and they represent following sequence of references: X, X+Z, X+2*Z, X+3*Z, …, X+K*Z, …(while (X+K*Z)<=Y).

Your task is to data-mine input data and for each set determine weather data were corrupted, which reference is occurring odd number of times, and count that reference.

Output

For each input data set you should print to standard output new line of text with either “no corruption” (low case) or two integers separated by single space (first one is reference that occurs odd number of times and second one is count of that reference).

Sample Input

1 10 1
2 10 1 1 10 1
1 10 1 1 10 1
4 4 1
1 5 1
6 10 1

Sample Output

1 1
no corruption
4 3

Source

/*
* @Author: Lyucheng
* @Date: 2017-07-29 20:58:28
* @Last Modified by: Lyucheng
* @Last Modified time: 2017-08-02 09:59:49
*/
/*
题意:每次给你X,Y,Z表示产品序列 X,X+Z,X+2*Z,X+3*Z,...,X+k*Z(X+K*Z<Y),让你判断哪个产品名出现过的次数不是偶数次 思路:异或判断哪个出现过奇数次,然后map计数 错误:上面的思路时间复杂度会炸掉的,这个题连数据范围都没有 改进:换种思路,看了题解才想到,二分答案,因为之多有一个是奇数个访问的,所以访问次数的前缀和一定从这个数变成奇数
利用这个性质来二分答案 注意的点:这个题数据范围不清晰,要用无符号longlong,并且用I64d输入,cout输出,我试了其他的方式都错了,还有读入空
行要单独处理
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <sstream> #define MAXN 1024
#define MAXM 1000005
#define MAX 0xffffffff
#define MIN 0
#define ULL unsigned long long
using namespace std; char str[MAXN];
ULL X[MAXM],Y[MAXM],Z[MAXM];
ULL res;
int n; inline ULL getsum(ULL m){
ULL sum=;
for(int i=;i<n;i++){
if(m>=Y[i]){
sum+=(Y[i]-X[i])/Z[i]+;
}else if(m>=X[i]){
sum+=(m-X[i])/Z[i]+;
}
}
return sum;
} inline void init(){
n=;
res=;
} int main(){
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(gets(str)){
init();
if(strlen(str)>=){//不是空的
sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]);
res^=( (Y[n]-X[n])/Z[n]+);
n++;
}
while(gets(str)!=NULL){
if(strlen(str)>=){//不是空的
sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]);
res^=( (Y[n]-X[n])/Z[n]+);
n++;
}else{
break;
}
}//读入完成
if(n==){
continue;
}
if(!(res&)){//如果调用次数本身就是偶数
cout << "no corruption" << endl;
continue;
}
ULL l=MIN,r=MAX,m;
while(r-l>){
m=(l+r)/;
if(getsum(m)%==MIN){//前缀和是偶数的
l=m+;
}else{//前缀和是奇数的
r=m;
}
}
cout<<l<<" "<<getsum(l)-getsum(l-)<<endl;
}
return ;
}

poj 3484 Showstopper的更多相关文章

  1. POJ 3484 Showstopper(二分答案)

    [题目链接] http://poj.org/problem?id=3484 [题目大意] 给出n个等差数列的首项末项和公差.求在数列中出现奇数次的数.题目保证至多只有一个数符合要求. [题解] 因为只 ...

  2. Divide and conquer:Showstopper(POJ 3484)

    Showstopper 题目大意:数据挖掘是一项很困难的事情,现在要你在一大堆数据中找出某个数重复奇数次的数(有且仅有一个),而且要你找出重复的次数. 其实我一开始是没读懂题意的...主要是我理解错o ...

  3. POJ 3484

    Showstopper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1060   Accepted: 303 Descri ...

  4. POJ 3484 二分

    Showstopper Description Data-mining huge data sets can be a painful and long lasting process if we a ...

  5. ProgrammingContestChallengeBook

    POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 ...

  6. POJ 1064 1759 3484 3061 (二分搜索)

    POJ 1064 题意 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长度相同的绳子的话,这K条绳子每条最长能有多长?答案保留小数点后2位. 思路 二分搜索.这里要注意精度问题,代码中有详细说 ...

  7. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  8. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  9. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

随机推荐

  1. Failed to load the JNI shared library "XXXXXXX"

    今天启动Eclipse的时候出现了这个问题,经过查找, 一般来说这种问题都是因为eclipse 和Java 的兼容性不一致所导致的. 1) 查看Eclipse 和Java 版本 那么我们需要分别查看下 ...

  2. Web 项目更改项目名

    简单的记录web开发中基本的操作. 更改项目名 直接修改 找到原项目中的.project 文件,更改中项目名称.然后在同目录下找到.mymetadata 文件 并更改name.context-root ...

  3. RMQ问题第一弹

    今天,我给大家分享一下我在学习 RMQ 问题过程中对该问题的理解. RMQ (Range Minimum/Maximum Query ):中文名为"区间最值查询".RMQ 问题指的 ...

  4. [原创]MinHook测试与分析(x64下 E9,EB,CALL指令测试,且逆推测试微软热补丁)

    依稀记得第一次接触Hook的概念是在周伟民先生的书中-><<多任务下的数据结构与算法>>,当时觉得Hook很奇妙,有机会要学习到,正好近段日子找来了MiniHook,就一 ...

  5. TCP/IP(二)物理层详解

    前言 在前面说了一下,计算机网络的大概内容,没有去深刻的去了解它,这篇文章给大家分享一下物理层! 我们知道ISO模型是七层,TCP/IP模型是五层,而tcp/ip协议只将七层概括为4层,我们将学习其中 ...

  6. Quartz学习——Quartz大致介绍(一)

    1. 介绍 Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目,是完全由java开发的一个开源的任务日程管理系统,"任务进度管理器"就是 ...

  7. 【转】常用Maven插件

    我们都知道Maven本质上是一个插件框架,它的核心并不执行任何具体的构建任务,所有这些任务都交给插件来完成,例如编译源代码是由maven- compiler-plugin完成的.进一步说,每个任务对应 ...

  8. C# 7.0 新特性:本地方法

    C# 7.0:本地方法 VS 2017 的 C# 7.0 中引入了本地方法,本地方法是一种语法糖,允许我们在方法内定义本地方法.更加类似于函数式语言,但是,本质上还是基于面向对象实现的. 1. 本地方 ...

  9. Ionic3学习笔记(五)动画之使用 animate.css

    本文为原创文章,转载请标明出处 目录 前言 animate.css 的使用 animate.scss 的使用 1. 前言 animate.css 是一款强大的.跨浏览器的预设CSS3动画库,内置了很多 ...

  10. cors解决ajax请求跨域问题

    Access-Control-Allow-Origin: * 适用tomcat部署的项目 在web.xml里添加以下内容 <filter> <filter-name>CorsF ...