Advertisement
Galebickosikasa

Untitled

Oct 15th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
  2. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
  3. // #pragma comment(linker, "/stack:200000000"]
  4.  
  5. #include <iostream>
  6. #include <vector>
  7. #include <cmath>
  8. #include <algorithm>
  9. #include <unordered_set>
  10. #include <unordered_map>
  11. #include <set>
  12. #include <map>
  13. #include <queue>
  14. #include <deque>
  15. #include <bitset>
  16. #include <stack>
  17. #include <random>
  18. #include <fstream>
  19. #include <sstream>
  20. #include <chrono>
  21.  
  22. #define fi first
  23. #define se second
  24. #define pb push_back
  25. #define ll long long
  26. #define ld long double
  27. #define hm unordered_map
  28. #define pii pair<int, int>
  29. #define sz(a) (int)a.size()
  30. #define all(a) a.begin(), a.end()
  31. #define cinv(v) for (auto& x: v) cin >> x
  32. #define fr(i, n) for (int i = 0; i < n; ++i)
  33. #define fl(i, l, n) for (int i = l; i < n; ++i)
  34.  
  35. #define int ll
  36.  
  37. template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
  38. template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
  39.  
  40. using namespace std;
  41.  
  42. #ifdef __LOCAL
  43. #define dbg(x) cerr << #x << " : " << x << '\n'
  44. const int maxn = 20;
  45. #else
  46. #define dbg(x)
  47. const int maxn = 2e5 + 20;
  48. #endif
  49.  
  50. //tg: @galebickosikasa
  51.  
  52. ostream& operator << (ostream& out, vector<int>& v) {
  53. for (auto& x: v) out << x << ' ';
  54. return out;
  55. }
  56.  
  57. ostream& operator << (ostream& out, pii& v) {
  58. out << v.fi << ", " << v.se;
  59. return out;
  60. }
  61.  
  62. istream& operator >> (istream& in, pii& a) {
  63. in >> a.fi >> a.se;
  64. return in;
  65. }
  66.  
  67. const ll inf = (ll) 2e9;
  68. const ld pi = asin (1) * 2;
  69. const ld eps = 1e-8;
  70. const ll mod = (ll)1e9 + 7;
  71. const ll ns = 97;
  72.  
  73. mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  74.  
  75. ld check (ld ax, ld ay, ld bx, ld by, ld x) {
  76. return sqrt ((ax - x) * (ax - x) + ay * ay) + sqrt ((bx - x) * (bx - x) + by * by);
  77. }
  78.  
  79. ld bs (ld ax, ld ay, ld bx, ld by) {
  80. ld l = 0, r = 101;
  81. fr (i, 500) {
  82. ld m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
  83. ld a = check (ax, ay, bx, by, m1), b = check (ax, ay, bx, by, m2);
  84. if (a < b) r = r - (r - l) / 3;
  85. else l = l + (r - l) / 3;
  86. }
  87. return r;
  88. }
  89.  
  90. signed main () {
  91. ios_base::sync_with_stdio(false);
  92. cin.tie(nullptr);
  93. cout.tie(nullptr);
  94. cout.precision (20);
  95. cout << fixed;
  96. ld ax, ay, bx, by;
  97. cin >> ax >> ay >> bx >> by;
  98. cout << bs (ax, ay, bx, by) << '\n';
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. }
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement