标签:
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)
Total Submission(s): 1338 Accepted Submission(s):
735
#include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #define MAX 10100 #define DD double using namespace std; struct node { int time,pos; }s[MAX]; bool cmp(node a,node b) { return a.time<b.time; } int main() { int t,n,m,i,j,k; scanf("%d",&t); k=0; while(t--) { scanf("%d",&n); DD sum=0,ans=0; for(i=0;i<n;i++) scanf("%d%d",&s[i].time,&s[i].pos); sort(s,s+n,cmp); for(i=0;i<n-1;i++) { DD sum=(s[i+1].pos-s[i].pos)*1.0/(s[i+1].time-s[i].time); ans=max(fabs(sum),ans); } printf("Case #%d: %.2lf\n",++k,ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4888002.html