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 ...
随机推荐
- 重命名Oracle数据库的表空间(Renaming a Tablespace)
重命名一个表空间时,Oracle会在数据字典.控制文件和数据文件的头部更新这个表空间名. 注意,重命名一个表空间不会重命名相关联的数据文件. 重命名代码示例如下: SQL> alter tabl ...
- TreeSet,Comparator
ThreeSet能够对集合中的对象排序,当TreeSet想集合中加入一个对象时,会把它插入到有序的对象序列中. ThreeSet自带了一个排序方法,这个方法规定了一般数据的排序规则,如果用户想要规定自 ...
- CheckBox和RadioButton
多选按钮CheckBox的使用方法和常用的监听器:OnClickListener.OnCheckedChangeListener 在activity_main.xml中使用LinearLayout布局 ...
- oracle 11g 修改默认监听端口1521
OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...
- ASP.NET内置对象之Request传递请求对象
Request对象是HttpRequest类的一个实例,Request对象用于读取客户端在Web请求期间发送的HTTP值.Request对象常用的属性如下所示. q QueryString: ...
- oracle 分析函数(笔记)
分析函数是oracle数据库在9i版本中引入并在以后版本中不断增强的新函数种类.分析函数提供好了跨行.多层次聚合引用值的能力.分析函数所展现的效果使用传统的SQL语句也能实现,但是实现方式比较复杂,效 ...
- Objective-C 内存管理原则
内存管理方针 用于内存管理的基本模型采用引用计数的环境之中提供的组合方法中定义在NSObject协议和标准方法的命名约定.NSObject类也定义了一个方法:dealloc,当调用一个对象时自动回收, ...
- 10个 iOS 用户暂可以嘲笑 Android 的特点
Android 与 iOS 设备之间的争斗从未停止,毕竟一切高科技产品的理念和实际表现方式都不相同.就拿 Android 来说,很多功能令用户并 不太开心,甚至是令人愤怒,下面让我们来简单的盘点 10 ...
- mysql TRUNCATE
保留小数点 select truncate(field1,2) from table1 field3 字段类型为decimal(20,3)
- 条款3:尽可能地使用const
如下为const修饰的几种类型: char name[] = "benxintuzi"; char* p1 = name; // non-const ...