//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
int T;
double a,b,l,r;
using namespace std;
double f(double x) {
return b*sqrt(1.0-(x*x)/(a*a));
}
double sim(double x,double y) {
double mid=((x+y)/2.0);
return (y-x)/6.0*(f(x)+4.0*f(mid)+f(y));
}
double calc(double l,double r,double eps) {
double mid=((l+r)/2.0);
double tp=sim(l,mid)+sim(mid,r),tpp=sim(l,r);
if(tp-tpp<=eps*15.0) return tp+(tp-tpp)/15.0;
else return calc(l,mid,eps/2.0)+calc(mid,r,eps/2.0);
}
int main() {
scanf("%d",&T);
while(T--) {
scanf("%lf%lf%lf%lf",&a,&b,&l,&r);
printf("%.3lf
",calc(l,r,1e-5)*2.0);
}
return 0;
}
这里还有一道自适应辛普森模板