hdu4768(二分)
来源:互联网 发布:FMC汽车知乎 编辑:程序博客网 时间:2024/06/01 11:19
Flyer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3352 Accepted Submission(s): 1257
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
Source
2013 ACM/ICPC Asia Regional Changchun Online
#include<stdio.h>#include<iostream>#include<string.h>#include<algorithm>using namespace std;typedef long long ll;ll a[20010],b[20010],c[20010];int n;ll check(ll mid){ll s=0;for(int i=0;i<n;i++){ll x=min(mid,b[i]);if(x>=a[i]){s+=(x-a[i])/c[i]+1;}}return s;}int main(){while(scanf("%d",&n)!=EOF){for(int i=0;i<n;i++)scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);ll l,r;l=0;r=1LL<<31;while(l<r){ll mid=(l+r)>>1;if(check(mid)%2==0)l=mid+1; else r=mid;}if(l==1LL<<31)puts("DC Qiang is unhappy.");else{while(check(l)%2==0) l--;printf("%lld %lld\n",l,check(l)-check(l-1));}}return 0;}
阅读全文
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)详解
- 机器学习第3章第2节 : 绘制正余弦图像
- FFmpeg H264/H265边界填充一
- 如何理解typedef关键字
- 自动驾驶技术的六个级别
- saltstack在模板中引用变量的方法
- hdu4768(二分)
- vmware 虚拟机的介绍使用及问题
- wordpress安装插件提示需要ftp账号和密码解决
- hdu 4641 K-string (sam)
- CFormView中控件无法响应Ctrl+C和Ctrl+V消息的解决办法
- VS2015在release模式下进行调试
- 重视到了时间复杂度
- Java 9新特性详解
- 乱码问题整理