博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 3484 Showstopper
阅读量:6821 次
发布时间:2019-06-26

本文共 3201 字,大约阅读时间需要 10 分钟。

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 12 10 11 10 11 10 11 10 14 4 11 5 16 10 1

Sample Output

1 1no corruption4 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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define MAXN 1024#define MAXM 1000005#define MAX 0xffffffff#define MIN 0#define ULL unsigned long longusing namespace std;char str[MAXN];ULL X[MAXM],Y[MAXM],Z[MAXM];ULL res;int n;inline ULL getsum(ULL m){ ULL sum=0; for(int i=0;i
=Y[i]){ sum+=(Y[i]-X[i])/Z[i]+1; }else if(m>=X[i]){ sum+=(m-X[i])/Z[i]+1; } } return sum;}inline void init(){ n=0; res=0;}int main(){ // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(gets(str)){ init(); if(strlen(str)>=2){ //不是空的 sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]); res^=( (Y[n]-X[n])/Z[n]+1); n++; } while(gets(str)!=NULL){ if(strlen(str)>=2){ //不是空的 sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]); res^=( (Y[n]-X[n])/Z[n]+1); n++; }else{ break; } }//读入完成 if(n==0){ continue; } if(!(res&1)){ //如果调用次数本身就是偶数 cout << "no corruption" << endl; continue; } ULL l=MIN,r=MAX,m; while(r-l>0){ m=(l+r)/2; if(getsum(m)%2==MIN){ //前缀和是偶数的 l=m+1; }else{ //前缀和是奇数的 r=m; } } cout<
<<" "<
<

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/7272335.html

你可能感兴趣的文章
PhalApi:[1.11] 快速入门: 接口开发示例 源码 图文
查看>>
分享插件
查看>>
HTML 页面中Buton 按钮提交,一个很坑的问题
查看>>
kitchen测试salt-formulas
查看>>
拿Nginx 部署你的静态网页
查看>>
23种设计模式
查看>>
openstack命令整理
查看>>
使用xtrabackup备份mysql8.0.16
查看>>
安装apache遇到的几个错误及解决办法 [error] Apache2.2: Service is already installed.
查看>>
Spring Security源码分析一:Spring Security认证过程
查看>>
Dubbo环境搭建
查看>>
[数据结构]插入排序与希尔排序
查看>>
如何高效利用GitHub
查看>>
Server-sent Event 简单介绍
查看>>
nginx 常用的几个命令
查看>>
解决命令行的乱码以及编码的问题
查看>>
Linux 程序获取环境变量
查看>>
vim设置括号自动补全
查看>>
windows环境eclipse开发C++程序
查看>>
svn 常用命令总结
查看>>