A Curious Matt

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)
Total Submission(s): 1338    Accepted Submission(s):
735

Problem Description
There is a curious man called Matt.

One day,
Matt's best friend Ted is wandering on the non-negative half of the number line.
Matt finds it interesting to know the maximal speed Ted may reach. In order to
do so, Matt takes records of Ted’s position. Now Matt has a great deal of
records. Please help him to find out the maximal speed Ted may reach, assuming
Ted moves with a constant speed between two consecutive records.

 
Input
The first line contains only one integer T, which
indicates the number of test cases.

For each test case, the first line
contains an integer N (2 ≤ N ≤ 10000),indicating the number of
records.

Each of the following N lines contains two integers
ti and xi (0 ≤ ti, xi
106), indicating the time when this record is taken and Ted’s
corresponding position. Note that records may be unsorted by time. It’s
guaranteed that all ti would be distinct.

 
Output
For each test case, output a single line “Case #x: y”,
where x is the case number (starting from 1), and y is the maximal speed Ted may
reach. The result should be rounded to two decimal places.
 
Sample Input
2
3
2 2
1 1
3 4
3
0 3
1 5
2 0
 
Sample Output
Case #1: 2.00
Case #2: 5.00

Hint

In the first sample, Ted moves from 2 to 4 in 1 time unit. The speed 2/1 is maximal.
In the second sample, Ted moves from 5 to 0 in 1 time unit. The speed 5/1 is maximal.

 
 
时间长不编题真的不行了  一道水题花好长时间..........................
题意:给你一个人 在一些时刻的位置,让你求出这个人所能达到的最大速度。
 
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define MAX 10100
#define DD double
using namespace std;
struct node
{
int time,pos;
}s[MAX];
bool cmp(node a,node b)
{
return a.time<b.time;
}
int main()
{
int t,n,m,i,j,k;
scanf("%d",&t);
k=0;
while(t--)
{
scanf("%d",&n);
DD sum=0,ans=0;
for(i=0;i<n;i++)
scanf("%d%d",&s[i].time,&s[i].pos);
sort(s,s+n,cmp);
for(i=0;i<n-1;i++)
{
DD sum=(s[i+1].pos-s[i].pos)*1.0/(s[i+1].time-s[i].time);
ans=max(fabs(sum),ans);
}
printf("Case #%d: %.2lf\n",++k,ans);
}
return 0;
}

  

hdoj 5112 A Curious Matt的更多相关文章

  1. hdu 5112 A Curious Matt

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5112 A Curious Matt Description There is a curious ma ...

  2. HDU 5112 A Curious Matt 水题

    A Curious Matt Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  3. HDU 5112 A Curious Matt (2014ACM/ICPC亚洲区北京站-重现赛)

    A Curious Matt Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) ...

  4. 水题:HDU 5112 A Curious Matt

    Description There is a curious man called Matt. One day, Matt's best friend Ted is wandering on the ...

  5. HDU 5120 A Curious Matt(2014北京赛区现场赛A题 简单模拟)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5112 解题报告:扫一遍 #include<cstdio> #include<cstr ...

  6. 2014ACM/ICPC亚洲区北京站

    1001  A Curious Matt 求一段时间内的速度单位时间变化量,其实就是直接求出单位时间内的,如果某段时间能达到最大那么这段时间内必定有一个或一小段单位时间内速度变化是最大的即局部能达到最 ...

  7. 2014年亚洲区域赛北京赛区现场赛A,D,H,I,K题解(hdu5112,5115,5119,5220,5122)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 下午在HDU上打了一下今年北京区域赛的重现,过了5题,看来单挑只能拿拿铜牌,呜呜. ...

  8. 2014 ACM/ICPC Asia Regional Beijing Site

    1001 A Curious Matt 1002 Black And White 1003 Collision 1004 Dire Wolf 1005 Everlasting L 1006 Fluor ...

  9. hdoj 5119 Happy Matt Friends 背包DP

    Happy Matt Friends Time Limit: 6000/6000 MS (Java/Others) Memory Limit: 510000/510000 K (Java/Others ...

随机推荐

  1. iOS多线程常用类说明--备用参考

    iOS的多线程,涉及到如下一些类,这里集中做个介绍,免得混淆. 1.NSTimer 很显然,这是定时器类 2.NSTask iOS 不支持 NSTask 在很多并发操作的时候,多线程太耗资源,也太危险 ...

  2. Ajax简单实现文件异步上传的多种方法

    1. 认识FormData对象 FormData是Html5新加进来的一个类,可以模拟表单数据 构造函数 FormData (optional HTMLFormElement form) (可选) 解 ...

  3. 将 Photoshop CC 2015.5 英文界面换成中文, 英文与中文界面互换

    注:转载或引用请注明出处 在英文的win server 2012 r2 上安装PS CC 2015.5 时,安装程序自动按成了英文版的PS,那么如何将英文换成中文呢? 网上大多讲的都是将中文换成英文, ...

  4. html&nbsp;&nbsp;特殊字符(转)

    有些字符在HTML里有特别的含义,比如小于号<就表示HTML Tag的开始,这个小于号是不显示在我们最终看到的网页里的.那如果我们希望在网页中显示一个小于号,该怎么办呢? 这就要说到HTML字符 ...

  5. loadrunner_analysis技巧_filter和group by

    很多时候要对loadrunner的收集结果进行一些选择性的过滤,比如我们使用阶梯式增加用户的方式,在初期vu没有全部准备好的情况下,此时的曲线不能体现实际情况,所以我们可以用 filter这个工具来帮 ...

  6. [jobdu]孩子们的游戏(圆圈中最后剩下的数)

    这道题就是典型的约瑟夫环问题.http://blog.csdn.net/wuzhekai1985/article/details/6628491 一开始想了一下用数组来做,就是模拟方法,同时记录一下是 ...

  7. char和QChar(Unicode的编码与内存里的值还不是一回事)

    char类型是c/c++中内置的类型,描述了1个字节的内存信息的解析.比如: char gemfield=’g’; 那么在由gemfield标记的这块内存的大小就是1个字节,信息就是01100111, ...

  8. Delphi GDI+基本用法总结

    GDI+以前只是听说过,还没怎么用过,这段时间用了用,觉得挺好用的.在这里总结一下.留个备忘. GDI+(Graphics Device Interface plus)是Windows XP中的一个子 ...

  9. ruby使用IO类读写文件

    path="test.txt" port=open(path) begin port.each_line{|line| p line.to_s } ensure port.clos ...

  10. 【HDOJ】1857 Word Puzzle

    trie树.以puzzle做trie树内存不够,从puzzle中直接找串应该会TLE.其实可以将查询组成trie树,离线做.扫描puzzle时注意仅三个方向即可. /* 1857 */ #includ ...