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. 1 10 1
  2. 2 10 1
  3.  
  4. 1 10 1
  5. 1 10 1
  6.  
  7. 1 10 1
  8. 4 4 1
  9. 1 5 1
  10. 6 10 1

Sample Output

  1. 1 1
  2. no corruption
  3. 4 3

Source

  1. /*
  2. * @Author: Lyucheng
  3. * @Date: 2017-07-29 20:58:28
  4. * @Last Modified by: Lyucheng
  5. * @Last Modified time: 2017-08-02 09:59:49
  6. */
  7. /*
  8. 题意:每次给你X,Y,Z表示产品序列 X,X+Z,X+2*Z,X+3*Z,...,X+k*Z(X+K*Z<Y),让你判断哪个产品名出现过的次数不是偶数次
  9.  
  10. 思路:异或判断哪个出现过奇数次,然后map计数
  11.  
  12. 错误:上面的思路时间复杂度会炸掉的,这个题连数据范围都没有
  13.  
  14. 改进:换种思路,看了题解才想到,二分答案,因为之多有一个是奇数个访问的,所以访问次数的前缀和一定从这个数变成奇数
  15. 利用这个性质来二分答案
  16.  
  17. 注意的点:这个题数据范围不清晰,要用无符号longlong,并且用I64d输入,cout输出,我试了其他的方式都错了,还有读入空
  18. 行要单独处理
  19. */
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <iostream>
  23. #include <algorithm>
  24. #include <vector>
  25. #include <queue>
  26. #include <set>
  27. #include <map>
  28. #include <string>
  29. #include <math.h>
  30. #include <stdlib.h>
  31. #include <time.h>
  32. #include <sstream>
  33.  
  34. #define MAXN 1024
  35. #define MAXM 1000005
  36. #define MAX 0xffffffff
  37. #define MIN 0
  38. #define ULL unsigned long long
  39. using namespace std;
  40.  
  41. char str[MAXN];
  42. ULL X[MAXM],Y[MAXM],Z[MAXM];
  43. ULL res;
  44. int n;
  45.  
  46. inline ULL getsum(ULL m){
  47. ULL sum=;
  48. for(int i=;i<n;i++){
  49. if(m>=Y[i]){
  50. sum+=(Y[i]-X[i])/Z[i]+;
  51. }else if(m>=X[i]){
  52. sum+=(m-X[i])/Z[i]+;
  53. }
  54. }
  55. return sum;
  56. }
  57.  
  58. inline void init(){
  59. n=;
  60. res=;
  61. }
  62.  
  63. int main(){
  64. // freopen("in.txt", "r", stdin);
  65. // freopen("out.txt", "w", stdout);
  66. while(gets(str)){
  67. init();
  68. if(strlen(str)>=){//不是空的
  69. sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]);
  70. res^=( (Y[n]-X[n])/Z[n]+);
  71. n++;
  72. }
  73. while(gets(str)!=NULL){
  74. if(strlen(str)>=){//不是空的
  75. sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]);
  76. res^=( (Y[n]-X[n])/Z[n]+);
  77. n++;
  78. }else{
  79. break;
  80. }
  81. }//读入完成
  82. if(n==){
  83. continue;
  84. }
  85. if(!(res&)){//如果调用次数本身就是偶数
  86. cout << "no corruption" << endl;
  87. continue;
  88. }
  89. ULL l=MIN,r=MAX,m;
  90. while(r-l>){
  91. m=(l+r)/;
  92. if(getsum(m)%==MIN){//前缀和是偶数的
  93. l=m+;
  94. }else{//前缀和是奇数的
  95. r=m;
  96. }
  97. }
  98. cout<<l<<" "<<getsum(l)-getsum(l-)<<endl;
  99. }
  100. return ;
  101. }

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. 蓝色巨人IBM

    1911年IBM的前身CRT建立,在中华民国时期就与中国有很多商业合作,中国中央银行,中国银行,黄埔造船厂,建国后直到中美建交,IBM与中国的关系越来越紧密,今晚看了一遍关于蓝色巨人的视频,收益匪浅. ...

  2. Web 开发模式演变历史和趋势

    前不久徐飞写了一篇很好的文章:Web 应用的组件化开发.本文尝试从历史发展角度,说说各种研发模式的优劣. 一.简单明快的早期时代 可称之为 Web 1.0 时代,非常适合创业型小项目,不分前后端,经常 ...

  3. 数据库服务器构建和部署列表(For SQL Server 2012)

    前言 我们可能经常安装和部署数据库服务器,但是可能突然忘记了某个设置,为后来的运维造成隐患.下面是国外大牛整理的的检查列表. 其实也包含了很多我们平时数据库配置的最佳实践.比如TEMPDB 文件的个数 ...

  4. 如何从两个List中筛选出相同的值

    问题 现有社保卡和身份证若干,想要匹配筛选出一一对应的社保卡和身份证. 转换为List socialList,和List idList,从二者中找出匹配的社保卡. 模型 创建社保卡类 /** * @a ...

  5. MySQL+Keepalived配置高可用

    服务器环境: 主mysql:192.168.1.163 从mysql:192.168.1.126 VIP:192.168.1.50 一.mysql配置主从同步 1.配置主mysql服务器 vim /e ...

  6. java学习——java中的反射学习笔记

    Java--reflect 一.Class类的使用 什么是Class类? 1:在面向对象的世界中,万事万物皆对象. java语言中,静态的成员,普通数据类型类是不是对象呢? 是,对象!是类的对象! 类 ...

  7. Spring Boot Document Part II(下)

    Part II. Getting started 11. 开发第一个Spirng Boot Application使用Spring Boot的关键特征开发一个基于JAVA Web的“Hello Wor ...

  8. ThreadLocal的理解与应用场景分析

    对于Java ThreadLocal的理解与应用场景分析 一.对ThreadLocal理解 ThreadLocal提供一个方便的方式,可以根据不同的线程存放一些不同的特征属性,可以方便的在线程中进行存 ...

  9. FZU 1919 -- K-way Merging sort(记忆化搜索)

    题目链接 Problem Description As we all known, merge sort is an O(nlogn) comparison-based sorting algorit ...

  10. Elevator poj3539

    Elevator Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 1072   Accepted: 287 Case Time ...