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. Eclipse 启动问题:'Initilizing Java Tooling' has encountered a problem(。。。)

    一.问题描述: . 二.分析及解决 ...

  2. C#正则表达式之字符替换

    string strTest= "www.BaiDu.com",strRst=""; //忽略大小写,将strTest中的BaiDu替换为baidu Regex ...

  3. WEB黑客工具箱之FireBug介绍

    Firefox扩展Firebug是一个全功能的Web 应用程序调试器,可以协助Web黑客洞悉复杂的Web 应用程序的内部工作机制.它有两种版本:一种可以跨浏览器使用的组件Firebug Lite,另一 ...

  4. phpexcelreader超级简单使用

    phpexcelreader超级简单使用 该php类可以到官网下载:http://www.codeplex.com/PHPExcel,下载的文件不能直接使用要看下面的备注. 备注: 1.要将olere ...

  5. javaweb学习总结(四十)——编写自己的JDBC框架

    一.元数据介绍 元数据指的是"数据库"."表"."列"的定义信息. 1.1.DataBaseMetaData元数据 Connection.g ...

  6. Altium Designer 常用快捷键总结

    原理图:1:按住shift  拖动某个元件,可快速复制.2:按住鼠标滚轮 鼠标上下滑动 放大缩小.3:按住Ctrl 按住鼠标右键 鼠标上下滑动也放大缩小.4:按住Ctrl 拖动某个元件 可以移动位置 ...

  7. Android 自定义title样式

    requestWindowFeature(featrueId),它的功能是启用窗体的扩展特性.参数是Window类中定义的常量.一.枚举常量1.DEFAULT_FEATURES:系统默认状态,一般不需 ...

  8. Styles and Themens(5)样式文件Style.xml中各元素的含义

    Style Resource See also Styles and Themes A style resource defines the format and look for a UI. A s ...

  9. C#中的泛型详解

    泛型(generic)是C#语言2.0和通用语言运行时(CLR)的一个新特性.泛型为.NET框架引入了类型参数(type parameters)的概念.类型参数使得设计类和方法时,不必确定一个或多个具 ...

  10. 【HDOJ】2295 Radar

    DLX+二分. /* 2295 */ #include <iostream> #include <string> #include <map> #include & ...