| 比赛 |
ICPC复现(AI数据) |
评测结果 |
AAAAAA |
| 题目名称 |
球 |
最终得分 |
100 |
| 用户昵称 |
VTXE |
运行时间 |
0.862 s |
| 代码语言 |
C++ |
内存使用 |
3.87 MiB |
| 提交时间 |
2026-05-26 21:04:02 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const double pi=acos(-1.0);
ll T;
double x,y,z,r1,r2;
double d1,d2;
double ans;
double h1,h2,v1,v2;
int main(){
freopen("qiu.in","r",stdin);
freopen("qiu.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while (T--){
cin>>x>>y>>z>>r1>>r2;
d1=x*x+y*y+z*z;
d2=sqrt(d1);
ans=0;
if (d2>=r1+r2){
ans=0;
}else if (d2<=fabs(r1-r2)){
double r=min(r1,r2);
ans=4.0*pi*r*r*r/3.0;
}else{
h1=r1-(r1*r1-r2*r2+d1)/(2.0*d2);
h2=r2-(r2*r2-r1*r1+d1)/(2.0*d2);
// h1=r1-(d2-sqrt(r2*r2));
// h2=r2-(d2-sqrt(r1*r1));
v1=pi*h1*h1*(3*r1-h1)/3.0;
v2=pi*h2*h2*(3*r2-h2)/3.0;
ans=v1+v2;
}
cout<<fixed<<setprecision(6)<<ans<<'\n';
}
return 0;
}
/*
4
10 10 10 10 10
0 0 10 30 10
0 10 10 20 20
20 20 20 10 10
*/