一道数学题,解个2次方程就行了。。。
主要的几个式子
#include<cstdio> #include<cmath> int main() { int T; scanf("%d",&T); while(T--){ int W,H,x,xe,ye; double u; scanf("%d%d%d%d%d%lf",&W,&H,&x,&xe,&ye,&u); int Y = ye - H, X = xe - W; int C = X*ye-Y*(xe-x); int X2 = X*X, Y2 = Y*Y; double lamda = (u*u)*(X2+Y2) - X2; double a = (lamda - Y2)*X2; double b = -2*X*lamda*C; double c = lamda*C*C; double delta = b*b - 4*a*c; if(delta>=0){ double h = (sqrt(delta) - b)/(2*a); if(h>H) printf("Impossible\n"); else { if(h < 0) printf("0\n"); else printf("%.4lf\n",h); } }else { printf("Impossible\n"); } } return 0; }
时间: 2024-10-21 10:21:42