HDU5162Jump and Jump...
来源:互联网 发布:mysql批量insert into 编辑:程序博客网 时间:2024/06/10 07:33
Jump and Jump...
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1355 Accepted Submission(s): 687
Problem Description
There are n kids and they want to know who can jump the farthest. For each kid, he can jump three times and the distance he jumps is maximum distance amount all the three jump. For example, if the distance of each jump is (10, 30, 20), then the farthest distance he can jump is 30. Given the distance for each jump of the kids, you should find the rank of each kid.
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤100) , indicating the number of test cases. For each test case: The first line contains an integer n (2≤n≤3) , indicating the number of kids. For the next n lines, each line contains three integers ai,bi and ci (1≤ai,bi,ci,≤300 ), indicating the distance for each jump of the i -th kid. It's guaranteed that the final rank of each kid won't be the same (ie. the farthest distance each kid can jump won't be the same).
Output
For each test case, you should output a single line contain n integers, separated by one space. The i -th integer indicating the rank of i -th kid.
Sample Input
2310 10 1010 20 3010 10 2023 4 11 2 1
Sample Output
3 1 21 2HintFor the first case, the farthest distance each kid can jump is 10, 30 and 20. So the rank is 3, 1, 2.
这是BEST CODE里面的题目,题意就不讲了恩,不懂题意的直接看看中文版的;
http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=563&pid=1001
题目比较简单直接给出代码:
/*对数据分析,最多只有三个孩子,最少有两个孩子;分情况考虑就好了,当n等于2的时候和当n等于3的时候,复制粘连就好了;每一个孩子只跳三次,那么我们只要对每一个孩子进行下排序就好了,这里我用的是降序排序,就得到a[0] b[0] c[0],分别是三个孩子的跳远的最大值;然后对这几个最大值进行排序,最后控制下输出格式就好了;*/#include<iostream>#include<algorithm>#include<cstring>#include<cstdio>using namespace std;bool Cmp(const int &a,const int &b)//降序排序;{return a > b;}int main(){int T,x,y,z,d[3];cin >> T;int n;int a[3], b[3], c[3];while (T--){cin >> n;for (int i = 0; i < 3; i++)cin >> a[i];for (int i = 0; i < 3; i++)cin >> b[i];sort(a, a + 3, Cmp);sort(b, b + 3, Cmp);if (n == 3){for (int i = 0; i < 3; i++)cin >> c[i];sort(c, c + 3, Cmp);z = c[0];}if (n == 3){d[0] = a[0]; d[1] = b[0]; d[2] = c[0];sort(d, d + 3, Cmp);for (int i = 0; i < 3; i++){if (a[0] == d[i])cout << i+1;}for (int i = 0; i < 3; i++){if (b[0] == d[i])cout <<" "<<i+1;}for (int i = 0; i < 3; i++){if (c[0] == d[i])cout << " " << i+1 << endl;;}}else{d[0] = a[0]; d[1] = b[0];sort(d, d + 2, Cmp);for (int i = 0; i < 3; i++){if (a[0] == d[i])cout << i + 1;}for (int i = 0; i < 3; i++){if (b[0] == d[i])cout << " " << i + 1<<endl;}}}return 0;}
1 0
- HDU5162Jump and Jump...
- 1001Jump and Jump...
- 1001 Jump and Jump...
- Jump and Jump...
- hdu 5612 Jump and Jump
- HDU 5162 Jump and Jump...
- hdu 5162 Jump and Jump...
- Jump and Jump... HDU 5162
- HDU 5162Jump and Jump...
- Bestcoder 27 # A jump and jump
- Bestcoder_Round#27_1001-Jump and jump...(HDUOJ_5162)
- 【BestCoder】 HDOJ 5162 Jump and Jump...
- hdu 5162 Jump and Jump...(模拟)
- showModalDialog close and jump to
- LeetCode 55. Jump Game and 45. Jump Game II 题解
- Jump Game I and II leetcode
- [leetcode] Jump Game I and II
- Jump
- STC89C52单片机控制超声波测距模块SR04模块,带温度矫正,flash存储源程序,显示在数码管上
- Java设计模式_行为型_责任链模式_差旅报销如此简单
- 使用注解的Hibernate many-to-many映射
- ClickOnce发布WCF客户端程序(VS2008 NetFramework 2.0 SP2 编译版本)思路
- Java并发库(四):传统线程同步通信技术
- HDU5162Jump and Jump...
- 在 ExtJS 中使用 Font Awesome
- virtualbox中win7虚拟机与mac主机传输文件之共享文件夹方式
- PL0编译器分析与语法扩展
- jQuery dataTable使用详解
- 阿里YunOS 5发布:稳居国内手机操作系统前三
- Bootstrap Manifest Generator(BMG) 生成的product.xml 试分析
- Bsie:让 Bootsrap 兼容 IE6-8 浏览器
- idea中常用的快捷键