結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,g,n) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>;
using P = pair<int,int>;
template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;}

static constexpr double eps = 1e-9;
static constexpr double pi = acos(-1);

void solve() {
  ll xa, ya, za, xb, yb, zb, ra, rb;
  cin >> xa >> ya >> za >> ra >> xb >> yb >> zb >> rb;
  double d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb)+(za-zb)*(za-zb));
  if (d >= ra+rb-eps) {
    cout << 0 << endl;
    return;
  }
  if (d <= ra-rb+eps) {
    double ans = 4.0*rb*rb*rb*pi/3.0;
    printf("%.10lf\n", ans);
    return;
  }
  if (d <= rb-ra+eps) {
    double ans = 4.0*ra*ra*ra*pi/3.0;
    printf("%.10lf\n", ans);
    return;
  }
  double x = (double(ra*ra-rb*rb)/d+d)/2.0, y = d-x;
  // cout << x << " " << y << endl;
  double t1 = (x*x*x+2.0*ra*ra*ra)/3.0-x*ra*ra;
  double t2 = (y*y*y+2.0*rb*rb*rb)/3.0-y*rb*rb;
  printf("%.10lf\n", (t1+t2)*pi);
}

int main() {
  int t;
  cin >> t;
  while(t--) solve();
  return 0;
}
0