fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define YeS (yes ? "YES\n" : "NO\n");
  5. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t)new char | 1));
  6. template <typename T>
  7. T Rand(T low, T high)
  8. {
  9. return uniform_int_distribution<T>(low, high)(rng);
  10. }
  11. void fast(string name = "", string name2 = "")
  12. {
  13. ios::sync_with_stdio(false);
  14. cin.tie(0);
  15. cout.tie(0);
  16. if (name.size())
  17. freopen((name + ".in").c_str(), "r", stdin);
  18. if (name2.size())
  19. freopen((name2 + ".out").c_str(), "w", stdout);
  20. }
  21. double x,y,z;
  22. double tx,ty,tz,ra;
  23. bool check(double nr){
  24. if(nr*2>min({x,y,z}))return false;
  25. double cens[8][3]={
  26. {nr,nr,nr},{nr,nr,z-nr},{nr,y-nr,nr},{x-nr,nr,nr},{x-nr,y-nr,nr},{x-nr,nr,z-nr},{nr,y-nr,z-nr},{x-nr,y-nr,z-nr}
  27. };
  28. for(auto&i:cens){
  29. double cx=i[0],cy=i[1],cz=i[2];
  30. double dis=sqrt((tx-cx)*(tx-cx)+(ty-cy)*(ty-cy)+(tz-cz)*(tz-cz));
  31. if(dis>=nr+ra)return true;
  32. }
  33. return false;
  34. }
  35. void solve()
  36. {
  37. cin>>x>>y>>z;
  38. cin>>tx>>ty>>tz>>ra;
  39. double l=0,r=1e9;
  40. for(int i =0;i<1000000;i++){
  41. double mid =(l+r)/2;
  42. if(check(mid))l=mid;
  43. else r=mid;
  44. }
  45. cout<<fixed<<setprecision(15);
  46. cout<<(check(r)?r:l)<<"\n";
  47. }
  48. signed main()
  49. {
  50. fast();
  51. int t = 1;
  52. // cin >> t;
  53. while (t--)
  54. {
  55. solve();
  56. }
  57. }
Success #stdin #stdout 0.06s 5320KB
stdin
Standard input is empty
stdout
0.000000000000000