题目连接

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

A Curious Matt

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 \leq N \leq 10000)$,indicating the number of records.

Each of the following $N$ lines contains two integers $t_i$ and $x_i$ $(0 \leq t_i, x_i \leq 10^6)$, 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

简单题,权当练习一下英文。。

 1 #include<algorithm>
 2 #include<iostream>
 3 #include<cstdlib>
 4 #include<cstring>
 5 #include<cstdio>
 6 #include<vector>
 7 #include<map>
 8 using std::max;
 9 using std::cin;
10 using std::cout;
11 using std::endl;
12 using std::fabs;
13 using std::sort;
14 using std::pair;
15 using std::vector;
16 #define pb(e) push_back(e)
17 #define sz(c) (int)(c).size()
18 #define mp(a, b) make_pair(a, b)
19 #define all(c) (c).begin(), (c).end()
20 #define iter(c) decltype((c).begin())
21 #define cls(arr,val) memset(arr,val,sizeof(arr))
22 #define cpresent(c, e) (find(all(c), (e)) != (c).end())
23 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
24 #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
25 const int N = 10010;
26 typedef unsigned long long ull;
27 struct Node {
28     int t, x;
29     bool operator<(const Node &b) const {
30         return t < b.t;
31     }
32 }rec[N];
33 int main() {
34 #ifdef LOCAL
35     freopen("in.txt", "r", stdin);
36     freopen("out.txt", "w+", stdout);
37 #endif
38     int t, n, k = 1;
39     scanf("%d", &t);
40     while (t--) {
41         double ans = 0.0;
42         scanf("%d", &n);
43         rep(i, n) scanf("%d %d", &rec[i].t, &rec[i].x);
44         sort(rec, rec + n);
45         for (int i = 1; i < n; i++) {
46             ans = max(ans, fabs((double)rec[i].x - rec[i - 1].x) / (rec[i].t - rec[i - 1].t));
47         }
48         printf("Case #%d: %.2lf\n", k++, ans);
49     }
50     return 0;
51 }

View Code

转载于:https://www.cnblogs.com/GadyPu/p/4604126.html

hdu 5112 A Curious Matt相关推荐

  1. HDU 5112 A Curious Matt 水题

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

  2. 2014_beijing_onsite

    5112 A Curious Matt 签到,排序题目 5113 Black And White 5*5的方格,dfs+剪枝 5114 Collision 线性方程求解 扩展欧几里得 5115 Dir ...

  3. 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 ...

  4. 2014 ACM亚洲区域赛 - 北京现场赛

    2014 ACM亚洲区域赛 - 北京现场赛A - A Curious Matt一个排序,找最大值,overB - Black And White数据范围很小,单纯的暴力会TLE,看题解,染色问题有一个 ...

  5. pythonturtle画小白兔_使用Python+turtle绘制动画重现龟兔赛跑现场

    jQuery 基础(3) -- jQuery 事件 jQuery 是为事件处理特别设计的.什么是事件?页面对不同访问者的响应叫做事件.事件处理程序指的是当 HTML 中发生某些事件时所调用的方法.实例 ...

  6. HDU 5119 Happy Matt Friends(递推)

    http://acm.hdu.edu.cn/showproblem.php?pid=5119 题意: 给出n个数和一个上限m,求从这n个数里取任意个数做异或运算,最后的结果不小于m有多少种取法. 思路 ...

  7. HDU 5119 Happy Matt Friends ——(背包DP)

    题意:有最多40个数字,取任意个数字他们的异或和>=k则是可行的方案,问有多少种可行的方案. 分析:dp[now][j]表示当前这个值的种类数,那么转移方程为dp[now][j] = dp[pr ...

  8. HDU 5119 Happy Matt Friends(DP || 高斯消元)

    题目链接 题意 : 给你n个数,让你从中挑K个数(K<=n)使得这k个数异或的和小于m,问你有多少种异或方式满足这个条件. 思路 : 正解据说是高斯消元.这里用DP做的,类似于背包,枚举的是异或 ...

  9. HDU 5115 Dire Wolf 区间dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5115 Dire Wolf Time Limit: 5000/5000 MS (Java/Others ...

最新文章

  1. 怎么转换html格式文件怎么打开,html格式怎么转换
  2. java 报表导出_Java Excel报表导出Demo
  3. pycharm点击右上角退出程序时terminate和disconnect区别?(别用disconnect)
  4. cd rw 多少次_程序员:想知道你每天按了多少次键盘吗?
  5. 再不学习我们就out了
  6. 外设驱动库开发笔记3:AD527x系列数字电位器驱动
  7. PHP5时间相差八小时问题[三种方法]
  8. 4090万美元成交!马斯克又卖出三处住宅以兑现“无房产”诺言
  9. linux文本模式无法打字,文本终端模式下中文输入法(Fcitx)配置(openSUSE Leap 42.1)...
  10. 莽荒纪手游源码/服务端!
  11. IEEE 会议模板介绍
  12. 西门子cpu指示灯含义_CPU中的指示灯亮的意思
  13. 清除博科光纤交换机所有配置信息
  14. java多线程listview_Android_listview分页加载更多
  15. 推送微信公众号模板消息通知(Java版)
  16. python运行后闪退_怎样让python运行完了不直接退出?
  17. uniapp 跳转外部链接
  18. [Android] Codec paramter
  19. 2019最新升级全能版vbox硬件级虚拟机系统 vm去虚拟化修改信息工具 批量启动克隆 virtualbox CPA网赚挂机电商
  20. Java格式化字符串

热门文章

  1. 8086汇编 贪吃蛇 源代码
  2. 贪心 - 按要求补齐数组
  3. html导航条置顶,jquery导航菜单栏固定悬浮顶部实现效果
  4. 设计模式——工厂模式(二)
  5. C++中的const成员函数(函数声明后加const,或称常量成员函数)用法详解
  6. 禁用一个计算机用户,系统小技巧:Windows 10账户删除 禁用与启用
  7. c语言扫描图片的坐标,tc 如何在指定坐标处 输出bmp图片??
  8. java清除输出内容_java – 从JSch中的命令输出中删除shell东西...
  9. 为什么我喜欢EJB 3.0并且尤其喜欢EJB 3.1
  10. Oracle中REGEXP_SUBSTR函数