Advertisement
limimage

blyat'

Apr 22nd, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define endl "\n"
  4. using namespace std;
  5. using ll = long long;
  6. using ld = long double;
  7. using pii = pair<int, int>;
  8.  
  9. constexpr int N = 1e2+5;
  10. constexpr ld PI = 3.141592653589793238462643383279502884L,
  11. eps = 1e-9;
  12.  
  13. pair<ld, ld> p[5], parallel{1e18, 1e18};
  14.  
  15. ld dist(pair<ld, ld> a, pair<ld, ld> b)
  16. {
  17. auto [x1, y1] = a;
  18. auto [x2, y2] = b;
  19. return sqrtl((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  20. }
  21.  
  22. tuple<ld, ld, ld> equat(pair<ld, ld> f, pair<ld, ld> s)
  23. {
  24. auto [x1, y1] = f;
  25. auto [x2, y2] = s;
  26. ld a, b, c, z;
  27. a = y1-y2;
  28. b = x2-x1;
  29. c = -a*x1-b*y1;
  30. z = (c>0?-1:1)*sqrtl(a*a+b*b);
  31. a/=z;
  32. b/=z;
  33. c/=z;
  34. return {a, b, c};
  35. }
  36.  
  37. pair<ld, ld> intersec(ld a1, ld b1, ld m1, ld a2, ld b2, ld m2)
  38. {
  39. ld y, x;
  40. y = -1*(a1*m2-a2*m1)/(a1*b2-a2*b1);
  41. x = -1*(m1*b2-m2*b1)/(a1*b2-a2*b1);
  42. return {x, y};
  43. }
  44.  
  45. inline bool betw (ld l, ld r, ld x)
  46. {
  47. return min(l,r) <= x + eps && x <= max(l,r) + eps;
  48. }
  49.  
  50. bool check(pair<ld, ld> st, pair<ld, ld> fn, pair<ld, ld> p)
  51. {
  52. auto [x, y] = p;
  53. auto [x1, y1] = st;
  54. auto [x2, y2] = fn;
  55. return betw(x1, x2, x)&&betw(y1, y2, y);
  56. }
  57.  
  58. pair<ld, ld> operator+ (pair<ld, ld> a, pair<ld, ld> b)
  59. {
  60. auto [x1, y1] = a;
  61. auto [x2, y2] = b;
  62. return {x1+x2, y1+y2};
  63. }
  64.  
  65. pair<ld, ld> operator- (pair<ld, ld> a, pair<ld, ld> b)
  66. {
  67. b.first*=-1;
  68. b.second*=-1;
  69. return a+b;
  70. }
  71.  
  72. pair<ld, ld> operator/ (pair<ld, ld> a, ld val)
  73. {
  74. auto [x1, y1] = a;
  75. return {x1/val, y1/val};
  76. }
  77.  
  78. ld distance(pair<ld, ld> val)
  79. {
  80. auto l = p[2], r = p[3], m1 = p[2], m2 = m1, ans = m1;
  81. for (int i = 0; i < 300; i++)
  82. {
  83. m1 = l+(r-l)/3;
  84. m2 = r-(r-l)/3;
  85. if (dist(val, m1)<dist(val, m2))
  86. {
  87. ans = m1;
  88. r = m2;
  89. }
  90. else
  91. {
  92. ans = m2;
  93. l = m1;
  94. }
  95. }
  96. return dist(ans, val);
  97. }
  98.  
  99. ostream& operator<< (ostream& out, const pair<ld, ld>& p)
  100. {
  101. out << p.first << " " << p.second;
  102. }
  103.  
  104. istream& operator>> (istream& in, pair<ld, ld>& p)
  105. {
  106. in >> p.first >> p.second;
  107. }
  108.  
  109. void Solve()
  110. {
  111. freopen("line3.in", "r", stdin);
  112. freopen("line3.out", "w", stdout);
  113. ld a, b, c, r, z, nc[2];
  114. cin >> a >> b >> c >> r;
  115. z = (c>0?-1:1)*dist({a, b}, {0,0});
  116. a/=z, b/=z, c/=z;
  117. if (b!=0)
  118. {
  119. p[0] = {1, (r-a-c)/b};
  120. p[1] = {1, (-r-a-c)/b};
  121. }
  122. else
  123. {
  124. p[0] = {(r-b-c)/a, 1};
  125. p[1] = {(r-b-c)/a, 1};
  126. }
  127. for (int i = 0; i < 2; i++)
  128. {
  129. auto [x, y] = p[i];
  130. nc[i] = -(a*x+b*y);
  131. }
  132. a*=z, b*=z, nc[0]*=z, nc[1]*=z;
  133. for (int i = 0; i < 2; i++)
  134. cout << fixed << setprecision(10) << a << " " << b << " " << nc[i] << endl;
  135. }
  136.  
  137. int main()
  138. {
  139. ios_base::sync_with_stdio(false);
  140. cin.tie(nullptr);
  141. cout.tie(nullptr);
  142. Solve();
  143. return 0;
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement