标签:style blog http io ar color os sp for
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5112
解题报告:扫一遍
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 #include<cmath> 6 using namespace std; 7 const int maxn = 1e6+5; 8 9 struct node 10 { 11 double t,x; 12 }rec[maxn]; 13 double Max(double a,double b) 14 { 15 return a > b? a : b; 16 } 17 bool cmp(node a,node b) 18 { 19 return a.t < b.t; 20 } 21 double Fabs(double d) 22 { 23 return d > 0? d:-1.0*d; 24 } 25 int main() 26 { 27 int T,n,kase = 1; 28 scanf("%d",&T); 29 while(T--) 30 { 31 scanf("%d",&n); 32 for(int i = 0;i < n;++i) 33 scanf("%lf%lf",&rec[i].t,&rec[i].x); 34 sort(rec,rec+n,cmp); 35 double ans = 0; 36 for(int i = 1;i < n;++i) 37 ans = Max(ans,Fabs(rec[i].x-rec[i-1].x) / (rec[i].t - rec[i-1].t)); 38 printf("Case #%d: %.2lf\n",kase++,ans); 39 } 40 return 0; 41 }
HDU 5120 A Curious Matt(2014北京赛区现场赛A题 简单模拟)
标签:style blog http io ar color os sp for
原文地址:http://www.cnblogs.com/xiaxiaosheng/p/4132394.html