Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. //#include <iterator>
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. typedef long double ld;
  7.  
  8. const int N = 1e5 + 7;
  9. const ll MOD = 1e9 + 7;
  10.  
  11. struct point
  12. {
  13. ld x;
  14. ld y;
  15. int i;
  16. };
  17.  
  18. int n;
  19. ld rr, xx;
  20. point a[1007];
  21. vector <point> v;
  22. bool g = false;
  23.  
  24. bool check(ld x, ld y)
  25. {
  26. if (g) cout << " " << fixed << setprecision(10) << x << ' ' << y << endl;
  27. for (int i = 0; i < (int) v.size(); i++)
  28. {
  29. ld x1 = v[i].x;
  30. ld y1 = v[i].y;
  31. ld dst = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
  32. if (g) cout << "x1 y1\n";
  33. if (g) cout << fixed << setprecision(3) << x1 << ' ' << y1 << endl;
  34. if (g) cout << fixed << setprecision(10) << dst << endl;
  35. if (dst <= 2 * rr)
  36. return false;
  37. }
  38. return true;
  39. }
  40. int main()
  41. {
  42. ios::sync_with_stdio(0);
  43. cin >> n >> rr;
  44. for (int i = 0; i < n; i++)
  45. {
  46. point f;
  47. cin >> xx;
  48. f.x = xx;
  49. f.y = 0;
  50. f.i = i;
  51. a[i] = f;
  52. }
  53. v.push_back(a[0]);
  54. v[0].y = rr;
  55. ld l, r, m;
  56. cout << fixed << setprecision(10) << rr << ' ';
  57. for (int i = 1; i < n; i++)
  58. {
  59. l = rr;
  60. r = (ld) 1e18;
  61. for (int j = 0; j <= 500; j++)
  62. {
  63. m = (l + r) / 2;
  64. if (a[i].x == 12 && m <= 100.0)
  65. g = true;
  66. if (check(a[i].x, m))
  67. r = m;
  68. else
  69. l = m;
  70. }
  71. a[i].y = r;
  72. v.push_back(a[i]);
  73. cout << fixed << setprecision(10) << r << endl;
  74. }
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement