結果

問題 No.3672 Volume 3D
コンテスト
ユーザー daiota
提出日時 2026-09-05 03:14:22
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 923 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,146 ms
コンパイル使用メモリ 211,700 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-09-05 03:14:27
合計ジャッジ時間 3,780 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)








const double pi=acos(-1.0);





int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;



	int T;
	cin >> T;
	while(T--){

		ll a,b,c,r;
		cin >> a >> b >> c >> r;

		ll a1,b1,c1,r1;
		cin >> a1 >> b1 >> c1 >> r1;


		ll d=(a-a1)*(a-a1)+(b-b1)*(b-b1)+(c-c1)*(c-c1);


		if((r+r1)*(r+r1)<=d){
			cout << 0 << endl;
		}

		else if(d<=(r-r1)*(r-r1)){

			ll R=min(r,r1);
			double V=4.0/3.0*pi*R*R*R;
			cout << fixed << setprecision(12) << V << endl;



		}
		else{

			double dd=sqrt(1.0*d);
			double x=(r*r-r1*r1+d)/(2.0*dd);
			double y=(r1*r1-r*r+d)/(2.0*dd);

			double v=pi/3.0*(2.0*r*r*r-3.0*r*r*x+x*x*x);
			double u=pi/3.0*(2.0*r1*r1*r1-3.0*r1*r1*y+y*y*y);

			cout << fixed << setprecision(12) << v+u << endl;

		}









	}






	return 0;

}
0