結果
| 問題 | No.3672 Volume 3D |
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2026-09-04 22:45:28 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 108 ms / 2,000 ms |
| + 360µs | |
| コード長 | 1,832 bytes |
| 記録 | |
| コンパイル時間 | 1,067 ms |
| コンパイル使用メモリ | 214,396 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-09-04 22:54:20 |
| 合計ジャッジ時間 | 4,846 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
// https://mathworld.wolfram.com/Sphere-SphereIntersection.html
#define ld long double
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int Q;cin>>Q;
while(Q--){
ll x1,y1,z1,RR;cin>>x1>>y1>>z1>>RR;
ll x2,y2,z2,rr;cin>>x2>>y2>>z2>>rr;
if(RR<rr){
swap(x1,x2);
swap(y1,y2);
swap(z1,z2);
swap(RR,rr);
}
ld R=RR,r=rr;
ld d=hypotl(hypotl(x1-x2,y1-y2),z1-z2);
//cout<<R<<" "<<r<<" "<<d<<" ";
ld pi=acosl(-1.0l);
if(d+r<=R){
ld V=pi*4*r*r*r/3;
cout<<fixed<<setprecision(25)<<V<<"\n";
}else if(R+r<d) cout<<0<<"\n";
else{
ld pi=acosl(-1.0l);
ld V=pi*(R+r-d)*(R+r-d)*(d*d+2*d*r-3*r*r+2*d*R+6*r*R-3*R*R);
V/=(12*d);
cout<<fixed<<setprecision(25)<<V<<"\n";
}
}
}
Rubikun