結果

問題 No.3672 Volume 3D
コンテスト
ユーザー HoyHoyCharhang
提出日時 2026-09-04 23:34:12
言語 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,606 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,882 ms
コンパイル使用メモリ 334,324 KB
実行使用メモリ 9,916 KB
最終ジャッジ日時 2026-09-04 23:34:27
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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;}

using ld = long double;
static constexpr ld pi = acos(-1);

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

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