Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 72 Accepted Submission(s): 18
1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2013-9-11 13:51:21 4 File Name :2013-9-11\1002.cpp 5 ************************************************ */ 6 7 #include <stdio.h> 8 #include <string.h> 9 #include <iostream> 10 #include <algorithm> 11 #include <vector> 12 #include <queue> 13 #include <set> 14 #include <map> 15 #include <string> 16 #include <math.h> 17 #include <stdlib.h> 18 #include <time.h> 19 using namespace std; 20 const double eps = 1e-6; 21 const int MAXN = 330; 22 int n; 23 double x[MAXN]; 24 double y[MAXN]; 25 double vx[MAXN]; 26 double vy[MAXN]; 27 28 double calc(double t) 29 { 30 double ret = 0; 31 for(int i = 0;i < n;i++) 32 for(int j = i+1;j < n;j++) 33 { 34 double x1 = x[i] + vx[i]*t; 35 double y1 = y[i] + vy[i]*t; 36 double x2 = x[j] + vx[j]*t; 37 double y2 = y[j] + vy[j]*t; 38 ret = max(ret,sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); 39 } 40 return ret; 41 } 42 double solve() 43 { 44 double l = 0, r = 1e10; 45 while(r-l >= eps) 46 { 47 double mid = (l+r)/2; 48 double midmid = (mid + r)/2; 49 double tmp1 = calc(mid); 50 double tmp2 = calc(midmid); 51 if(tmp2 > tmp1)r = midmid-eps; 52 else l = mid + eps; 53 } 54 return l; 55 } 56 57 int main() 58 { 59 //freopen("in.txt","r",stdin); 60 //freopen("out.txt","w",stdout); 61 int T; 62 scanf("%d",&T); 63 int iCase = 0; 64 while(T--) 65 { 66 iCase ++; 67 scanf("%d",&n); 68 for(int i = 0;i < n;i++) 69 scanf("%lf%lf%lf%lf",&x[i],&y[i],&vx[i],&vy[i]); 70 double t = solve(); 71 printf("Case #%d: %.2lf %.2lf\n",iCase,t,calc(t)); 72 } 73 return 0; 74 }