Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. double dist(double x, double y, double x1, double y1) {
  8. return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
  9. }
  10.  
  11. bool is_striped(double x, double y, double k) {
  12. if (dist(0, 0, x, y) > k)
  13. return false;
  14. if (dist(0, k, x, y) > k)
  15. return false;
  16. if (dist(k, 0, x, y) > k)
  17. return false;
  18. if (dist(k, k, x, y) > k)
  19. return false;
  20. return true;
  21. }
  22.  
  23. int main() {
  24. int n, i, k, m;
  25. double x, y;
  26.  
  27. while (scanf("%d %d", &n, &k) && n) {
  28. m = 0;
  29. for (i = 0; i < n; i++) {
  30. scanf("%lf %lf", &x, &y);
  31. if (is_striped(x, y, k * 1.))
  32. m++;
  33. }
  34. printf("%.5lf\n", (m * k * k * 1.) / n);
  35. }
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement