Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- using ll = long long;
- using ld = long double;
- using pii = pair<int, int>;
- constexpr int N = 1e2+5;
- constexpr ld PI = 3.141592653589793238462643383279502884L,
- eps = 1e-9;
- pair<ld, ld> p[5], parallel{1e18, 1e18};
- ld dist(pair<ld, ld> a, pair<ld, ld> b)
- {
- auto [x1, y1] = a;
- auto [x2, y2] = b;
- return sqrtl((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
- }
- tuple<ld, ld, ld> equat(pair<ld, ld> f, pair<ld, ld> s)
- {
- auto [x1, y1] = f;
- auto [x2, y2] = s;
- ld a, b, c, z;
- a = y1-y2;
- b = x2-x1;
- c = -a*x1-b*y1;
- z = (c>0?-1:1)*sqrtl(a*a+b*b);
- a/=z;
- b/=z;
- c/=z;
- return {a, b, c};
- }
- pair<ld, ld> intersec(ld a1, ld b1, ld m1, ld a2, ld b2, ld m2)
- {
- ld y, x;
- y = -1*(a1*m2-a2*m1)/(a1*b2-a2*b1);
- x = -1*(m1*b2-m2*b1)/(a1*b2-a2*b1);
- return {x, y};
- }
- inline bool betw (ld l, ld r, ld x)
- {
- return min(l,r) <= x + eps && x <= max(l,r) + eps;
- }
- bool check(pair<ld, ld> st, pair<ld, ld> fn, pair<ld, ld> p)
- {
- auto [x, y] = p;
- auto [x1, y1] = st;
- auto [x2, y2] = fn;
- return betw(x1, x2, x)&&betw(y1, y2, y);
- }
- pair<ld, ld> operator+ (pair<ld, ld> a, pair<ld, ld> b)
- {
- auto [x1, y1] = a;
- auto [x2, y2] = b;
- return {x1+x2, y1+y2};
- }
- pair<ld, ld> operator- (pair<ld, ld> a, pair<ld, ld> b)
- {
- b.first*=-1;
- b.second*=-1;
- return a+b;
- }
- pair<ld, ld> operator/ (pair<ld, ld> a, ld val)
- {
- auto [x1, y1] = a;
- return {x1/val, y1/val};
- }
- ld distance(pair<ld, ld> val)
- {
- auto l = p[2], r = p[3], m1 = p[2], m2 = m1, ans = m1;
- for (int i = 0; i < 300; i++)
- {
- m1 = l+(r-l)/3;
- m2 = r-(r-l)/3;
- if (dist(val, m1)<dist(val, m2))
- {
- ans = m1;
- r = m2;
- }
- else
- {
- ans = m2;
- l = m1;
- }
- }
- return dist(ans, val);
- }
- ostream& operator<< (ostream& out, const pair<ld, ld>& p)
- {
- out << p.first << " " << p.second;
- }
- istream& operator>> (istream& in, pair<ld, ld>& p)
- {
- in >> p.first >> p.second;
- }
- void Solve()
- {
- freopen("line3.in", "r", stdin);
- freopen("line3.out", "w", stdout);
- ld a, b, c, r, z, nc[2];
- cin >> a >> b >> c >> r;
- z = (c>0?-1:1)*dist({a, b}, {0,0});
- a/=z, b/=z, c/=z;
- if (b!=0)
- {
- p[0] = {1, (r-a-c)/b};
- p[1] = {1, (-r-a-c)/b};
- }
- else
- {
- p[0] = {(r-b-c)/a, 1};
- p[1] = {(r-b-c)/a, 1};
- }
- for (int i = 0; i < 2; i++)
- {
- auto [x, y] = p[i];
- nc[i] = -(a*x+b*y);
- }
- a*=z, b*=z, nc[0]*=z, nc[1]*=z;
- for (int i = 0; i < 2; i++)
- cout << fixed << setprecision(10) << a << " " << b << " " << nc[i] << endl;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- Solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement