Advertisement
dmkozyrev

55.cpp

May 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #define _USE_MATH_DEFINES
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <vector>
  5.  
  6. struct Circle {
  7.     int xc, yc, r;
  8.    
  9.     Circle(int xc = 0, int yc = 0, int r = 0) : xc(xc), yc(yc), r(r) { }
  10.    
  11.     inline bool include (double x, double y) {
  12.         return (x-xc)*(x-xc) + (y-yc)*(y-yc) <= r*r;
  13.     }
  14. } A, B;
  15.  
  16. int main() {
  17.     freopen("input.txt", "rt", stdin);
  18.     freopen("output.txt", "wt", stdout);
  19.    
  20.     int r, s;
  21.    
  22.     scanf("%d %d %d %d %d %d", &A.xc, &A.yc, &B.xc, &B.yc, &r, &s);
  23.     A.r = B.r = r;
  24.    
  25.     int nsteps = 10000;
  26.    
  27.     double dx = 2*r, dy = 2*r;
  28.     dx /= nsteps;
  29.     dy /= nsteps;
  30.    
  31.     std::vector<double> x(nsteps), y(nsteps);
  32.    
  33.     x[0] = A.xc - r + dx / 2;
  34.     y[0] = A.yc - r + dy / 2;
  35.    
  36.     for (int i = 1; i < nsteps; ++i) {
  37.         x[i] = x[i-1] + dx;
  38.         y[i] = y[i-1] + dy;
  39.     }
  40.    
  41.     int count = 0;
  42.     for (auto & it_x : x)
  43.         for (auto & it_y : y)
  44.             if (A.include(it_x, it_y) && B.include(it_x, it_y))
  45.                 ++count;
  46.    
  47.     double same_square = 4.0 * count / nsteps / nsteps * r * r;
  48.    
  49.     printf((2*M_PI*r*r-same_square > s) ? "YES" : "NO");
  50.    
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement