hdu4768(二分)
来源:互联网 发布:织梦cms使用 编辑:程序博客网 时间:2024/06/08 13:17
Flyer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1632 Accepted Submission(s): 591
Problem Description
The new semester begins! Different kinds of student societies are all trying to advertise themselves, by giving flyers to the students for introducing the society. However, due to the fund shortage, the flyers of a society can only be distributed to a part of the students. There are too many, too many students in our university, labeled from 1 to 2^32. And there are totally N student societies, where the i-th society will deliver flyers to the students with label A_i, A_i+C_i,A_i+2*C_i,…A_i+k*C_i (A_i+k*C_i<=B_i, A_i+(k+1)*C_i>B_i). We call a student "unlucky" if he/she gets odd pieces of flyers. Unfortunately, not everyone is lucky. Yet, no worries; there is at most one student who is unlucky. Could you help us find out who the unfortunate dude (if any) is? So that we can comfort him by treating him to a big meal!
Input
There are multiple test cases. For each test case, the first line contains a number N (0 < N <= 20000) indicating the number of societies. Then for each of the following N lines, there are three non-negative integers A_i, B_i, C_i (smaller than 2^31, A_i <= B_i) as stated above. Your program should proceed to the end of the file.
Output
For each test case, if there is no unlucky student, print "DC Qiang is unhappy." (excluding the quotation mark), in a single line. Otherwise print two integers, i.e., the label of the unlucky student and the number of flyers he/she gets, in a single line.
Sample Input
21 10 12 10 145 20 76 14 35 9 17 21 12
Sample Output
1 18 1
题意:RT
思路:一共有n个人要发传单,每个人发给一些学生,不难看出为等差数列
因为题目保证至多有1个学生能收到奇数份传单
那么总的传单数为偶数,那么一定没有解
总的传单数位奇数则一定有解
那么可以学生代号的区间,看左右区间总的传单数,一定会有一边是奇数,一边是偶数,每次选奇数这边的区间即可
0 0
- hdu4768(二分)
- HDU4768:Flyer(二分)
- hdu4768(二分)
- HDU4768(二分)
- hdu4768 二分
- HDU4768:Flyer(二分)
- Flyer(二分 HDU4768)
- HDU4768 Flyer 二分
- HDU4768:Flyer(二分)
- hdu4768 非常规的二分
- HDU4768
- HDU4768 Flyer 二分|异或的性质|暴力
- 2013 ACM/ICPC Asia Regional Changchun Online Problem J & hdu4768 Flyer(二分)
- HDU4768 Flyer
- 二分图趣写(二分图)
- 整体二分(二分进阶)
- 二分(二分答案、二分搜索)与单调性
- 二分查找/二分搜索(binary_search)详解
- codeforces#266 总结
- 运算的优先级与结合性
- 黑马程序员——函数及数组
- D-ExecuteSQL
- C++标准库—自学教程与参考手册(第2版)翻译前言
- hdu4768(二分)
- 芹菜猪肉生煎包
- hdu4762(数学概率)
- 创新中国总决赛之行
- 使用iTween需谨慎 --- 内存泄露
- Adobe Native Extension(ANE)-Actionscript通过语音来控制你的android应用-Air for android
- ios 字符串的比较
- 设计模式之建造者模式
- 自定义 spring mvc 拦截器(近期项目需求实现)