POJ 3484
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 1060 | Accepted: 303 |
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
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; #define maxn 500005 typedef long long ll; char str[];
ll X[maxn],Y[maxn],Z[maxn];
int n; ll check(ll mid) {
ll sum = ;
for(int i = ; i <= n; ++i) {
if(mid < X[i]) continue;
sum += (min(mid,Y[i]) - X[i]) / Z[i] + ;
} //cout << "sum = " << sum << endl; return sum;
} void solve() { ll l = ,r = 1LL << ; while(l < r) {
ll mid = (l + r) >> ;
if(check(mid) % == ) l = mid + ;
else r = mid;
}
if (l == 1LL << )
puts("no corruption");
else
printf("%I64d %I64d\n" , l , (check(l) - check(l - ))); } int main()
{
//freopen("sw.in","r",stdin);
n = ; while(gets(str)) {
if(strlen(str) != ) {
++n;
sscanf(str,"%I64d %I64d %I64d",&X[n],&Y[n],&Z[n]);
//printf("%I64d %I64d %I64d\n",X[n],Y[n],Z[n]);
} if(strlen(str) == && n) {
solve();
n = ;
}
}
if(n) solve();
return ;
}
POJ 3484的更多相关文章
- POJ 3484 Showstopper(二分答案)
[题目链接] http://poj.org/problem?id=3484 [题目大意] 给出n个等差数列的首项末项和公差.求在数列中出现奇数次的数.题目保证至多只有一个数符合要求. [题解] 因为只 ...
- Divide and conquer:Showstopper(POJ 3484)
Showstopper 题目大意:数据挖掘是一项很困难的事情,现在要你在一大堆数据中找出某个数重复奇数次的数(有且仅有一个),而且要你找出重复的次数. 其实我一开始是没读懂题意的...主要是我理解错o ...
- poj 3484 Showstopper
Showstopper Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2236 Accepted: 662 Descri ...
- POJ 3484 二分
Showstopper Description Data-mining huge data sets can be a painful and long lasting process if we a ...
- POJ 1064 1759 3484 3061 (二分搜索)
POJ 1064 题意 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长度相同的绳子的话,这K条绳子每条最长能有多长?答案保留小数点后2位. 思路 二分搜索.这里要注意精度问题,代码中有详细说 ...
- ProgrammingContestChallengeBook
POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
随机推荐
- C++ STL vector 内存分配
vector为了支持快速的随机访问,vector容器的元素以连续方式存放,每一个元素都紧挨着前一个元素存储. 当vector添加一个元素时,为了满足连续存放这个特性,都需要重新分配空间.拷贝元素.撤销 ...
- hdu 1718 Rank
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1718 Rank Description Jackson wants to know his rank ...
- centos下安装nagios
摘要Nagios是一款开源的免费网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等. Nagios是一款开源的免费网络监视工具,能有效监控Wind ...
- c中static作用
1. static 变量 静态变量的类型 说明符是static. 静态变量当然是属于静态存储方式,但是属于静态存储方式的量不一定就是静态变量. 例如外部变量虽属于静态 存储方式,但不一定是静态变量 ...
- 单点登录 关于Cookie跨域的问题
public void ProcessRequest(HttpContext context) { HttpCookie cookie = new HttpCookie("name" ...
- .net中运用solr提升搜索效率(入门)
概述: 在开发网站的时候经常有要对某些内容查询的需求.此时如果基于数据库查询来做搜索功能,由于要对多个字段做模糊匹配,效率往往非常糟糕.这种情况就可以用Solr来提升搜索的效率.Solr是一个独立的企 ...
- Asp.Net Web API开发微信后台
如果说用Asp.Net开发微信后台是非主流,那么Asp.Net Web API的微信后台绝对是不走寻常路. 需要说明的是,本人认为Asp.Net Web API在开发很多不同的请求方法的Restful ...
- 在本地环境用虚拟机win2008 sever搭建VS2013 + SVN 代码版本控制环境
此文仅仅是自己笔记做个备忘.因为自己开发一些中小型的软件经常需要修修改改,特别是winform界面的大改动.经常需要对版本进行管理.而租用分布式服务器和远程服务器都不是自己想要的.本文结合虚拟机 + ...
- Android -- 经验分享
目录 代码中安装 ...
- 深入理解CSS3 animation的steps
在应用 CSS3 渐变/动画时,有个控制时间的属性 <timing-function> .它的取值中除了常用到的三次贝塞尔曲线以外,还有个让人比较困惑的 steps() 函数. steps ...