AmazingCounters.com

2014 北京区预赛【挖坑】

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

 

HDU5122 :K.Bro Sorting 一开始想成了上次西安热身赛的那题:求冒泡排序需要比较多少轮?仔细想想这两个问题还是有区别的

 1 #include<iostream>
 2 #include<cstdio>
 3 #include <queue>
 4 #include <string.h>
 5 #include <algorithm>
 6 #define inf 200000
 7 #define maxn 1000009
 8 using namespace std;
 9 int a[maxn];
10 int main()
11 {
12     int n,t,cas=0;
13     scanf("%d",&t);
14     while(t--)
15     {
16         int minx=0x3f3f3f3f,ans=0;
17         scanf("%d",&n);
18         for(int i=1;i<=n;i++)scanf("%d",&a[i]);
19         for(int i=n;i>=1;i--)
20         {
21             if(a[i]>minx)ans++;
22             minx=min(minx,a[i]);
23         }
24         printf("Case #%d: %d\n",++cas,ans);
25     }
26     return 0;
27 }
View Code

 

posted @ 2014-11-29 16:56  philippica  阅读(162)  评论(0编辑  收藏  举报