HDU5112 :A Curious Matt 水题 给你几个位置和到达该位置的时间 求最大速度 排一边序即可

 1 //poj3680
 2 #include <stdio.h>
 3 #include <iostream>
 4 #include <string.h>
 5 #include <algorithm>
 6 #include <queue>
 7 #define maxn 120090
 8 #define esp 0.00001
 9 #define inf 0x3f3f3f3f
10 using namespace std;
11 double abs(double a)
12 {
13     return a>0?a:-a;
14 }
15 struct T
16 {
17     int x;int y;
18 }a[maxn];
19 int cmp(T x,T y)
20 {
21     return x.x<y.x;
22 }
23 int main()
24 {
25     int t,n,cas=0;
26     scanf("%d",&t);
27     while(t--)
28     {
29         double ans=0;
30         scanf("%d",&n);
31         for(int i=1;i<=n;i++)
32         {
33             scanf("%d%d",&a[i].x,&a[i].y);
34         }
35         sort(a+1,a+1+n,cmp);
36         for(int i=2;i<=n;i++)
37         {
38             ans=max((double)abs(a[i].y-a[i-1].y)/abs(a[i].x-a[i-1].x),ans);
39         }
40         printf("Case #%d: %.2f\n",++cas,ans);
41     }
42     return 0;
43 }
View Code

相关文章:

  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2021-08-05
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
相关资源
相似解决方案