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. Android开发之读写联系人

    读写联系人需要用到android的ContentProvider 同时需要读和写联系人的权限 需要使用到联系人数据库中的 * raw_contacts表: * contact_id:联系人id * d ...

  2. JSON 之JAVA 解析

    一.   JSON (JavaScript Object Notation)一种简单的数据格式,比xml更轻巧. Json建构于两种结构:     1.“名称/值”对的集合(A collection ...

  3. bzoj4009

    这是一道神题,首先我们不难先到整体二分吧 下面的问题就是,求出对于每个水果,有多少盘子是他的子路径 直接考虑不是很容易,我们换个思路,考虑对于每个盘子,哪些水果能包含它 我们假设盘子a,b,dep[a ...

  4. [原]Unity3D深入浅出 - 光源组件(Light)

    Unity中提供了四种光源: Directional light: 方向光,类似太阳的日照效果. Point light: 点光源,类似蜡烛. Spotlight: 聚光灯,类似手电筒. Area L ...

  5. UVa 1599 (字典序最小的最短路) Ideal Path

    题意: 给出一个图(图中可能含平行边,可能含环),每条边有一个颜色标号.在从节点1到节点n的最短路的前提下,找到一条字典序最小的路径. 分析: 首先从节点n到节点1倒着BFS一次,算出每个节点到节点n ...

  6. [ZOJ 2836] Number Puzzle

    Number Puzzle Time Limit: 2 Seconds      Memory Limit: 65536 KB Given a list of integers (A1, A2, .. ...

  7. I.MX6 U-boot Kernel backlight setting

    /********************************************************************* * I.MX6 U-boot Kernel backlig ...

  8. ↗☻【HTML5秘籍 #BOOK#】第1章 HTML5简介

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  9. 巧用CSS文件愚人节恶搞(转)

    明天就是4月1日愚人节了,也就是那个可适度开玩笑.整蛊的日子了.如果你想和那些要上网的朋友或同事开个极客式玩笑,那就来试试这个国外网友Wes Bos分享的 CSS 文件吧. 一.打开浏览器的 Cust ...

  10. Iterator和ListIterator区别

    我们在使用List,Set的时候,为了实现对其数据的遍历,我们经常使用到了Iterator(迭代器).使用迭代器,你不需要干涉其遍历的过程,只需要每次取出一个你想要的数据进行处理就可以了. 但是在使用 ...