HDU2607 Let the Balloon Rise II
来源:互联网 发布:三层更新软件 编辑:程序博客网 时间:2024/05/18 03:34
Let the Balloon Rise II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 131 Accepted Submission(s): 37
Problem Description
Contest will be end at 17:00! How excited it is to see balloons floating around.
I knew you had solved the HDOJ 1004 Let the Balloon Rise already, so please settle the another version quickly. I have a lot of balloons and each has a color and I give each of them a number, same color has the same number. For example, red balloon is No.1, pink is No.2, black is No.3 . etc. I also have many rooms to store all the balloons.
There are some rules :
1. Every room stores several balloons but no two have the same color.
2. Collect all the balloons, we can find each color has even number of times of balloons except one.
Your task is to find which is the odd color and calculate its number of times.
I knew you had solved the HDOJ 1004 Let the Balloon Rise already, so please settle the another version quickly. I have a lot of balloons and each has a color and I give each of them a number, same color has the same number. For example, red balloon is No.1, pink is No.2, black is No.3 . etc. I also have many rooms to store all the balloons.
There are some rules :
1. Every room stores several balloons but no two have the same color.
2. Collect all the balloons, we can find each color has even number of times of balloons except one.
Your task is to find which is the odd color and calculate its number of times.
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 No.X, X+Z, X+2*Z, X+3*Z, …, X+K*Z, …(while (X+K*Z)<=Y). This line represents that in this room there exists (K+1) balloons whose No. is No.X, No.X+Z, No.X+2*Z, No.X+3*Z, …, No.X+K*Z, …etc.
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 No.X, X+Z, X+2*Z, X+3*Z, …, X+K*Z, …(while (X+K*Z)<=Y). This line represents that in this room there exists (K+1) balloons whose No. is No.X, No.X+Z, No.X+2*Z, No.X+3*Z, …, No.X+K*Z, …etc.
Output
For each input data set you should print to standard output new line of text with two integers separated by single space (first one is No. that occurs odd number of times and second one is count of that kind of balloon).
If all have even number of times output “None.”
If all have even number of times output “None.”
Sample Input
1 10 11 10 11 5 16 10 11 10 14 4 11 5 12 5 12 5 12 5 1
Sample Output
None.4 31 1
Author
WhereIsHeroFrom
Source
HDU 1st “Vegetable-Birds Cup” Programming Open Contest
#include <stdio.h>#include <string.h>#define maxn 100002int X[maxn], Y[maxn], Z[maxn];char buf[40];int main() { // freopen("data.in", "r", stdin); int i, id = 0, cnt = 0, ret = 0; // id记录数据块中条数, ret记录最终结果 while (gets(buf)) { if (*buf == NULL) { if (id) if (ret == 0) puts("None."); else { while (id--) { if (ret >= X[id] && ret <= Y[id] && (ret - X[id]) % Z[id] == 0) ++cnt; } printf("%d %d\n", ret, cnt); } id = cnt = ret = 0; continue; } sscanf(buf, "%d%d%d", &X[id], &Y[id], &Z[id]); for (i = X[id]; i <= Y[id]; i += Z[id]) ret ^= i; ++id; } if (id) if (ret == 0) puts("None."); else { while (id--) { if (ret >= X[id] && ret <= Y[id] && (ret - X[id]) % Z[id] == 0) ++cnt; } printf("%d %d\n", ret, cnt); } return 0;}
0 0
- HDU2607 Let the Balloon Rise II 二分
- HDU2607 Let the Balloon Rise II
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the balloon rise
- Let the Balloon Rise
- Let the Balloon Rise
- 外挂技术-逆向解密存放物品CALL缓冲区结构
- C#如何和SQL Server2008进行交互操作
- SharePoint 2013 数据库中手动更新用户信息
- Truck History
- Android 4.4 Kitkat Phone工作流程浅析(十一)__PSensor工作流程浅析
- HDU2607 Let the Balloon Rise II
- 使用object或者embed标签插入flash广告,其实可以只选其一
- CF 510B(Fox And Two Dots-图上找环)
- 教你写Android网络框架之Http请求的分发与执行
- net-snmp开发代理常见问题解决方案
- 对极几何与基础矩阵
- HDU-博彩问题-带分数
- 给定一个整数N,那么N的阶乘N!末尾有多少个0呢?例如:N=10,N!=3628800,N!的末尾有两个0。
- cocos2d-x游戏主要逻辑和结构