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 ...
随机推荐
- spring事物的七种事物传播属性行为及五种隔离级别
首先,说说什么事务(Transaction). 事务,就是一组操作数据库的动作集合.事务是现代数据库理论中的核心概念之一.如果一组处理步骤或者全部发生或者一步也不执行,我们称该组处理步骤为一个事务.当 ...
- JS把函数当作参数传递
getDescPage("commonPage","/page/common/tips/tips.html",init()); $("#"+ ...
- RAP开发入门-开发笔记
一.发布/运行 每次项目发布时需要在MANIFEST.MF->bulid中勾选依赖包.文件.代码等,避免报错 部署时项目可能会报一个baseline的错误,window->preferen ...
- Android:简单实现ViewPager+TabHost+TabWidget实现导航栏导航和滑动切换
viewPager是v4包里的一个组件,可以实现滑动显示多个界面. android也为viewPager提供了一个adapter,此adapter最少要重写4个方法: public int getCo ...
- 部署git server
http://gogs.io/docs/installation/install_from_binary.htmlwget http://gogs.dn.qbox.me/gogs_v0.6.5_lin ...
- C6011 正在取消对 null 指针的引用
- 微软职位内部推荐-Software Engineer II-Web app
微软近期Open的职位: The Office App Services team is working on the powerful Office Web Apps including Word ...
- zookeeper数据迁移
在不停机的情况下,实现集群之间数据迁移代码: private void create(ZooKeeper zk1, ZooKeeper zk2, String path) throws Excepti ...
- Android -- Layout布局文件里的android:layout_height等属性为什么会不起作用?
有的时候,我们配置好的布局文件,在加载完成添加到我们的Activity中后发现,并没有安装我们设置的属性来布局,比如我们设置了android:layout_marginTop="100dip ...
- VIMTUTOR《VIM教程》
=============================================================================== = 欢 迎 阅 ...