标签:
---------10.26
cf又滚粗了--
老是滚粗---还是太笨了啊---
没事--->_<
cf 591 d
http://codeforces.com/problemset/problem/591/D
看了贴吧里面的题解,说是要改参考系,把起点当成不动的,再二分时间
后来写了下不变参考系的,也可以
应该没什么区别的吧,,,
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 8 int x1,y1,x2,y2,v,T; 9 int vx,vy,wx,wy; 10 const int INF = (1<<30)-1; 11 12 int ok(double x){ 13 double x3,y3; 14 if(x <= T){ 15 x3 = 1.0*x1 + x*vx; 16 y3 = 1.0*y1 + x*vy; 17 } 18 if(x > T){ 19 x3 = 1.0*x1 + T*vx + (x-T)*wx; 20 y3 = 1.0*y1 + T*vy + (x-T)*wy; 21 } 22 double dis = (x3-x2)*(x3-x2)*1.0 + (y3-y2)*(y3-y2)*1.0; 23 return dis >= v*v*x*x*1.0; 24 } 25 26 void solve() { 27 double l = 0.0,r = 1.0*INF,mid; 28 for(int i = 0;i <= 1000;i++){ 29 mid = (l+r)*0.5; 30 if(ok(mid)) l = mid; 31 else r = mid; 32 33 // printf("l = %lf r = %lf mid = %lf\n",l,r,mid); 34 } 35 printf("%.16lf\n",l); 36 } 37 38 int main(){ 39 while(scanf("%d %d",&x1,&y1) != EOF){ 40 scanf("%d %d",&x2,&y2); 41 scanf("%d %d",&v,&T); 42 scanf("%d %d",&vx,&vy); 43 scanf("%d %d",&wx,&wy); 44 45 solve(); 46 47 } 48 return 0; 49 }
标签:
原文地址:http://www.cnblogs.com/wuyuewoniu/p/4912013.html