Advertisement
Guest User

Untitled

a guest
Dec 5th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.33 KB | None | 0 0
  1. /**
  2.  *  author:  fractal
  3.  *  timus:   288481RF
  4.  *  created: 03/25/21 01:16
  5. **/
  6.  
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9.  
  10. #define F first
  11. #define S second
  12. #define mp make_pair
  13. #define pb push_back
  14. #define pf push_front
  15. #define ppb pop_back
  16. #define ppf pop_front
  17. #define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
  18. #define sz(x) (int)x.size()
  19. #define len(x) (int)strlen(x)
  20. #define all(x) x.begin(), x.end()
  21. #define debug cerr << "OK\n";
  22. #define ub upper_bound
  23. #define lb lower_bound
  24. #define nl printf("\n");
  25. #define clbuff fflush(stdin);
  26.  
  27. mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());
  28. mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count());
  29.  
  30. typedef long long ll;
  31. typedef long double ld;
  32. typedef unsigned long long ull;
  33. typedef pair<int, int> pii;
  34. typedef pair<ll, ll> pll;
  35. typedef vector<int> vi;
  36. typedef vector<ll> vll;
  37. typedef vector<pii> vpii;
  38. typedef vector<pll> vpll;
  39. typedef set<int> si;
  40. typedef set<ll> sll;
  41. typedef set<pii> spii;
  42. typedef set<pll> spll;
  43. typedef multiset <int> msi;
  44. typedef multiset <ll> msll;
  45. typedef map <int, int> mi;
  46. typedef map <ll, ll> mll;
  47.  
  48. const int N = 1e5 + 2;
  49. const int M = 1e5;
  50. const int mod = 0;
  51. const int inf = 2e9 + 3;
  52. const ll INF = 1e18;
  53. const ld pi2 = 2.0 * 3.14159265359;
  54. const ld pi = 3.14159265359;
  55.  
  56. const int dx[4] = {1, -1, 0, 0};
  57. const int dy[4] = {0, 0, -1, 1};
  58.  
  59. void files(string s = "main") {
  60.     #ifndef PC
  61.         freopen((s + ".in").c_str(), "r", stdin);
  62.         freopen((s + ".out").c_str(), "w", stdout);
  63.     #endif
  64. }
  65.  
  66. int add(int a, int b) {
  67.     if (a + b < 0) return a + b + mod;
  68.     if (a + b >= mod) return a + b - mod;
  69.     return a + b;      
  70. }
  71.  
  72. int mul(int a, int b) {
  73.     return a * 1LL * b % mod;
  74. }
  75.  
  76. int binpow(int a, int n) {
  77.     int ret = 1;
  78.     while (n) {
  79.         if (n & 1) ret = mul(ret, a);
  80.         a = mul(a, a);
  81.         n >>= 1;
  82.     }
  83.     return ret;
  84. }
  85.  
  86. struct point {
  87.     ld x, y;
  88.    
  89.     point (ld x = 0, ld y = 0) : x(x), y(y) {}
  90.    
  91.     point norm() {
  92.         return point(-y, x);
  93.     }
  94.    
  95.     ld l() {
  96.         return sqrt(x * x + y * y);
  97.     }  
  98.    
  99.     point unit() {
  100.         return point(x / this->l(), y / this->l());
  101.     }
  102.    
  103.     point rot(ld alph) {
  104.         alph = alph * pi / 180.0;
  105.         ld c = cos(alph);
  106.         ld s = sin(alph);
  107.         return point(x * c - y * s, x * s + y * c);
  108.     }
  109.    
  110.     point operator*(const ld c) {
  111.         return point(x * c, y * c);
  112.     }
  113.    
  114.     point operator/(const ld c) {
  115.         return point(x / c, y / c);
  116.     }
  117.    
  118.     point operator+(const point a) {
  119.         return point(x + a.x, y + a.y);
  120.     }
  121.        
  122.    
  123.     point operator-(const point a) {
  124.         return point(x - a.x, y - a.y);
  125.     }
  126.    
  127.     ll operator*(const point a) {
  128.         return x * a.y - y * a.x;
  129.     }
  130.    
  131.     ll operator%(const point a) {
  132.         return x * a.x + y * a.y;
  133.     }
  134.    
  135.     bool operator<(const point a) {
  136.         if (x == a.x)
  137.             return y < a.y;
  138.         return x < a.x;
  139.     }
  140.    
  141.     bool operator==(const point a) {
  142.         return x == a.x && y == a.y;
  143.     }
  144.    
  145.     ld polar() {
  146.         if (x >= 0 && y >= 0)
  147.             return asin(y / this->l());
  148.         if (x >= 0 && y < 0)
  149.             return pi2 - asin(-y / this->l());
  150.         if (x < 0 && y >= 0)
  151.             return pi - asin(y / this->l());
  152.         if (x < 0 && y < 0)
  153.             return pi + asin(-y / this->l());
  154.     }
  155. };
  156.  
  157. ld dist(point a, point b) {
  158.     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
  159. }
  160.  
  161. int n;
  162. point p[N];
  163. vector <point> q;
  164.  
  165. void add(point a) {
  166.     while (sz(q) && q.back() == a)
  167.         q.ppb();
  168.     while (sz(q) > 1) {
  169.         int l = sz(q) - 1;
  170.         if ((a - q[l]) * (q[l] - q[l - 1]) > 0)
  171.             break;
  172.         if ((a - q[l]) * (q[l] - q[l - 1]) == 0 && (a - q[l]) % (q[l] - q[l - 1]) < 0)
  173.             break;
  174.         q.ppb();
  175.     }
  176.     q.pb(a);
  177. }
  178.  
  179. int main() {
  180.     speed;
  181.     files("tangent");
  182.     point p, q;
  183.     ld r;
  184.     cin >> p.x >> p.y >> r;
  185.     cin >> q.x >> q.y;
  186.     ld d = dist(q, p);
  187.     if (d == r) {
  188.         cout << 1 << '\n';
  189.         cout << fixed << setprecision(10) << q.x << " " << q.y << '\n';
  190.         return 0;
  191.     }
  192.     if (d < r) {
  193.         cout << 0 << '\n';
  194.         return 0;
  195.     }
  196.     ld l = sqrt(d * d - r * r);
  197.     ld c = (l * l - r * r + d * d) / (2.0 * d);
  198.     ld h = sqrt(l * l - c * c);
  199.     point go = (p - q).unit();
  200.     point v = q + go * c;
  201.     point a1 = v + (go.norm() * h);
  202.     point a2 = v - (go.norm() * h);
  203.     cout << 2 << '\n';
  204.     cout << fixed << setprecision(10) << v.x << " " << v.y << '\n';
  205.     cout << fixed << setprecision(10) << c << " " << h << '\n';
  206.     cout << fixed << setprecision(10) << a1.x << " " << a1.y << '\n';
  207.     cout << fixed << setprecision(10) << a2.x << " " << a2.y << '\n';
  208. }
  209.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement