A Curious Matt

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5112

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

题意

给你n个时间点和当前的位置,问你哪段的平均速度最大,是多少

题解:

暴力就好了

对着时间排序

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 2000000 + 500
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
//************************************************************************************** struct node
{
double t,x;
};
node a[];
bool cmp(node a,node b)
{
return a.t<b.t;
}
int main()
{
int t;scanf("%d",&t);
int cas = ;
while(t--){
int n;scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d%d",&a[i].t,&a[i].x);
sort(a+,a++n,cmp);
double ans = ;
for(int i=;i<n;i++)
ans = max(ans,abs(a[i+].x-a[i].x)/(a[i+].t-a[i].t));
printf("Case #%d: %.2f\n",cas++,ans);
}
}

HDU 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

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

  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. hdoj 5112 A Curious Matt

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

  5. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  6. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  7. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  8. hdu 1005:Number Sequence(水题)

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. hdu 1018:Big Number(水题)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

随机推荐

  1. bzoj1061: [Noi2008]志愿者招募

    线性规划与费用流.http://www.cnblogs.com/iiyiyi/p/5616080.html.数组范围开错了!!!然后2.31-1=0x7fffffff!=0x7f7f7f7f. 开始以 ...

  2. HAOI2007反素数

    1053: [HAOI2007]反素数ant Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1346  Solved: 732[Submit][Sta ...

  3. [swustoj 1095] 挖金子

    挖金子(1095) 题目描述 你在一个N*M的区域中,一开始在(1,1)的位置,每个位置有可能有金子,也有可能不能到达,也有可能有传送门.你只能往右或者下走,不能走出这个区域.当你位于传送门时,传送门 ...

  4. 嵌入式Linux系统运行流程图

    /************************************************************************ * 嵌入式Linux系统运行流程图 * 说明: * ...

  5. Java [leetcode 15] 3Sum

    问题描述: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find ...

  6. Skyline学习教程

    转自:http://yunjinzh.blog.sohu.com/165279318.html 当初开设这个blog的初衷就是将PPT与专业技术进行结合 将专业技术的介绍更加艺术化 但是之前一直都没有 ...

  7. jdk1.6新特性

    1.Web服务元数据 Java 里的Web服务元数据跟微软的方案基本没有语义上的区别,自从JDK5添加了元数据功能(Annotation)之后,SUN几乎重构了整个J2EE体 系, 由于变化很大,干脆 ...

  8. chrome启用本地文件

    chrome禁止本地浏览时加载本地其他文件,可以采用添加启动参数的方式来支持 添加参数为 --allow-file-access-from-files  或者 --disable-web-securi ...

  9. API性能测试基本性能指标及要求

    略 适用 Lifeix 所有后台应用. 1.事务(Transaction) 在web性能测试中,一个事务表示一个“从用户发送请求->web server接受到请求,进行处理-> web s ...

  10. opencv 在工业中的应用:圆孔定位

    在工业中产品或者夹具上经常有圆形孔,我们可以利用这些孔来对产品或者夹具进行定位.我用OPENCV写了个DEMO 程序,介绍如下: (1)首先点击打开图像按钮打开一幅图像 (2)进行一些参数设置 (3) ...