题目不是很难,把公式推出来以后直接代入,
/************************************************
┆ ┏┓ ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃ ┃ ┆
┆┃ ━ ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃ ┃ ┆
┆┃ ┻ ┃ ┆
┆┗━┓ ┏━┛ ┆
┆ ┃ ┃ ┆
┆ ┃ ┗━━━┓ ┆
┆ ┃ AC代马 ┣┓┆
┆ ┃ ┏┛┆
┆ ┗┓┓┏━┳┓┏┛ ┆
┆ ┃┫┫ ┃┫┫ ┆
┆ ┗┻ ┛ ┗┻┛ ┆
************************************************ */
#pragma warning (disable:4996)
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<set>
#include<map>
//#include<regex>
#include<stack>
#include<cstdlib>
#include<functional>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int Maxn = 2e5 + 10;
const int N = 100010;
double r,h;
double vx,vy,vz;
bool judge(double t ,double x0,double y0,double z0)
{
double x=x0+vx*t;
double y=y0+vy*t;
double z=z0+vz*t;
if(z>=0 && z<=h && x*x+y*y<=r*r){//t>=0 &&
return true;
}
return false;
}
int main()
{
int t;
scanf("%d",&t);
int cas=0;
while(t--){
double x0,y0,z0;
double a,b,c;
double t1,t2;
double tmp;
scanf("%lf%lf",&r,&h);
scanf("%lf%lf%lf",&x0,&y0,&z0);
scanf("%lf%lf%lf",&vx,&vy,&vz);
a=h*h*vx*vx+h*h*vy*vy-r*r*vz*vz;
b=2*x0*vx*h*h+2*y0*vy*h*h+2*h*vz*r*r-2*z0*vz*r*r;
c=h*h*x0*x0+h*h*y0*y0-r*r*h*h-r*r*z0*z0+2*h*z0*r*r;
tmp=b*b-4*a*c;
t1=(sqrt(tmp)-b)/(2.0*a),t2=-1.0*(b+sqrt(tmp))/(2.0*a);
double ans=1e18;
if(judge(t1,x0,y0,z0)){
ans=min(ans,t1);
}
if(judge(t2,x0,y0,z0)){
ans=min(ans,t2);
}
printf("Case %d: %.10f\n",++cas,ans);
}
return 0;
}