Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- //#include <iterator>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- const int N = 1e5 + 7;
- const ll MOD = 1e9 + 7;
- struct point
- {
- ld x;
- ld y;
- int i;
- };
- int n;
- ld rr, xx;
- point a[1007];
- vector <point> v;
- bool g = false;
- bool check(ld x, ld y)
- {
- if (g) cout << " " << fixed << setprecision(10) << x << ' ' << y << endl;
- for (int i = 0; i < (int) v.size(); i++)
- {
- ld x1 = v[i].x;
- ld y1 = v[i].y;
- ld dst = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
- if (g) cout << "x1 y1\n";
- if (g) cout << fixed << setprecision(3) << x1 << ' ' << y1 << endl;
- if (g) cout << fixed << setprecision(10) << dst << endl;
- if (dst <= 2 * rr)
- return false;
- }
- return true;
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin >> n >> rr;
- for (int i = 0; i < n; i++)
- {
- point f;
- cin >> xx;
- f.x = xx;
- f.y = 0;
- f.i = i;
- a[i] = f;
- }
- v.push_back(a[0]);
- v[0].y = rr;
- ld l, r, m;
- cout << fixed << setprecision(10) << rr << ' ';
- for (int i = 1; i < n; i++)
- {
- l = rr;
- r = (ld) 1e18;
- for (int j = 0; j <= 500; j++)
- {
- m = (l + r) / 2;
- if (a[i].x == 12 && m <= 100.0)
- g = true;
- if (check(a[i].x, m))
- r = m;
- else
- l = m;
- }
- a[i].y = r;
- v.push_back(a[i]);
- cout << fixed << setprecision(10) << r << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement