Showstopper
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的更多相关文章

  1. POJ 3484 Showstopper(二分答案)

    [题目链接] http://poj.org/problem?id=3484 [题目大意] 给出n个等差数列的首项末项和公差.求在数列中出现奇数次的数.题目保证至多只有一个数符合要求. [题解] 因为只 ...

  2. Divide and conquer:Showstopper(POJ 3484)

    Showstopper 题目大意:数据挖掘是一项很困难的事情,现在要你在一大堆数据中找出某个数重复奇数次的数(有且仅有一个),而且要你找出重复的次数. 其实我一开始是没读懂题意的...主要是我理解错o ...

  3. poj 3484 Showstopper

    Showstopper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2236   Accepted: 662 Descri ...

  4. POJ 3484 二分

    Showstopper Description Data-mining huge data sets can be a painful and long lasting process if we a ...

  5. POJ 1064 1759 3484 3061 (二分搜索)

    POJ 1064 题意 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长度相同的绳子的话,这K条绳子每条最长能有多长?答案保留小数点后2位. 思路 二分搜索.这里要注意精度问题,代码中有详细说 ...

  6. ProgrammingContestChallengeBook

    POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 ...

  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. (转)Android网络命令

    转自:http://www.cnblogs.com/shunyao8210/archive/2010/08/10/1796214.html ifconfig 1.       作用 ifconfig用 ...

  2. 行转列求和:不加 in 条件,sum的数据会不会准确?

    我的习惯写法,担心不加 in 条件 ,统计结果会包含其他的数据 SELECT ZWKMYE_KJND as 年度,ZWKMYE_KJQJ as 月份,ZWKMYE_DWBH as 单位, ' then ...

  3. Union-SQL Server学习笔记

    1.简单笔记 数据库查询语句中,通过UNION组合查询语句,可以将两个或更多查询的结果组合为单个结果集,该结果集包含组合查询中的所有查询的全部行. 利用UNION语句可以实现将不同数据表中符合条件,不 ...

  4. hdu 3371 Connect the Cities

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3371 Connect the Cities Description In 2100, since th ...

  5. hdu 1496 Equations

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...

  6. Douglas Crockford: entityify & deentityify

    大神之字符与字符实体的相互转换方法 // & to & if (!String.prototype.entityify) { String.prototype.entityify = ...

  7. Java之XStream之下划线问题

    XStream将Java对象序列为XML, 如果对象属性带有下划线,输出到XML时会转成"__"双下划. 网上很多资料说是Bug, XStream开发的大神没有哪么笨吧? 查了一下 ...

  8. golang构造函数与转换函数

    golang的每种类型, 凡是用type定义的类型, 其类型名既是其构造函数,也是其转换函数. 其中,构造函数后眼{...}, 转换函数后跟(...)

  9. IOS之表视图单元格删除、移动及插入

    1.实现单元格的删除,实现效果如下 - (void)viewDidLoad { [super viewDidLoad]; //设置导航栏 self.editButtonItem.title = @&q ...

  10. c/c++常用代码--string trim

    typedef std::basic_string<TCHAR> tstring; inline static void trim(tstring& s){    s.erase( ...