import java.util.*; public class Pizza_bob { public static int r, dx, dy, x, y; public static double p; public static Scanner in; public static int count; public static double maxarea; public static ArrayList areas; // areas that need to be checked public static void main(String[] args) { in = new Scanner(System.in); r = in.nextInt(); dx = in.nextInt(); dy = in.nextInt(); x = in.nextInt(); y = in.nextInt(); p = in.nextDouble(); maxarea = 0; // for now areas = new ArrayList(); // Find smallest bounding rectangle for the circle composed of // rectangular slices. int urx,ury,llx,lly; int kx1 = (int)Math.ceil(1.*(r-x)/dx); int ky1 = (int)Math.ceil(1.*(r-y)/dy); int kx2 = (int)Math.ceil(1.*(r+x)/dx); int ky2 = (int)Math.ceil(1.*(r+y)/dy); urx = x+dx*kx1; ury = y+dy*ky1; llx = x-dx*kx2; lly = y-dy*ky2; int kx = kx1+kx2; int ky = ky1+ky2; // Now process each smaller rectangle within the bounding rectangle. count = 0; for (int yi = 0; yi < ky; yi++) { for (int xi = 0; xi < kx; xi++) { int lx = llx+xi*dx,ly=lly+yi*dy,ux=llx+(xi+1)*dx,uy=lly+(yi+1)*dy; // easy cases first: // Case 1: no intersection: if (dist0(lx,ly) >= r*r && lx >= 0 && ly >= 0) { // quad I continue; } else if (dist0(ux,ly) >= r*r && ux <= 0 && ly >= 0) { // quad II continue; } else if (dist0(ux,uy) >= r*r && ux <= 0 && uy <= 0) { // quad III continue; } else if (dist0(lx,uy) >= r*r && lx >= 0 && uy <= 0) { // quad IV continue; } else // Case 2: rectangle contained in the circle: // See if all corners of the rectangle lie within the circle: if (dist0(ux,uy) <= r*r && dist0(ux,ly) <= r*r && dist0(lx,ly) <= r*r && dist0(lx,uy) <= r*r) { maxarea = dx*dy; // probably unnecessary continue; } else // Case 3: circle contained in the rectangle: this is the only piece! if (-r >= lx && r <= ux && -r >= ly && r <= uy) { System.out.println(0); System.exit(0); } else { // We first find intersection with the // upper-right quarter-circle, then we flip x-values and do it again // to find intersection with upper-left quarter-circle, // then flip y-values to get lower-left quarter-circle, // then flip x-values to get lower-right quarter-circle. double area = qcarea(lx,ly,ux,uy); area += qcarea(-ux,ly,-lx,uy); area += qcarea(-ux,-uy,-lx,-ly); area += qcarea(lx,-uy,ux,-ly); maxarea = Math.max(area,maxarea); areas.add(area); } } } for (Double d : areas) { if (d/maxarea < p+1.e-6) count++; } System.out.println(count); } public static double dist0(double x, double y) { return x*x + y*y; } // Return area of intersection of a rectangle with the upper right // quarter-circle. public static double qcarea(int lx, int ly, int ux, int uy) { if (ux < 0 || lx > r || uy < 0 || ly > r) { return 0; } // There are basically two cases: top of rectangle lies above y==r // or below. If above, then whole area is bounded by circle on top // and a horizontal line below (either bottom of rectangle or y==0). // If above, then might also be a rectangular component, depending on // whether circle crosses top edge of rectangle. // from xmin to xmid: find area of rectangular component // from xmid to xmax: find area under circular segment // First shot at integration bounds (may need adjusting) double xmin = Math.max(0,lx); // this won't change double xmax = Math.min(r,ux); // this MIGHT change double ymin = Math.max(0,ly); // this won't change double ymax = uy; // only used if there is a rectangular component to area double xmid = xmin; // this MIGHT change; default is "no rectanglular area" // Does the quarter circle intersect the top of the rectangle? If so, // need to split into two areas. // CASE 1: if (uy < r) { // rectangle top is below circle radius xmid = Math.sqrt(r*r - ymax*ymax); if (xmid <= xmin) { // intersects to the left of the rectangle xmid = xmin; // no rectangular piece } else if (xmid >= xmax ) { xmid = xmax; // no circular piece } } // CASE 2: uy > y. Then there is no rectangular piece--default setting // BOTH CASES: see if circle intersects bottom of rectangle (we already // know that ymin <= r) double temp = Math.sqrt(r*r - ymin*ymin); if (temp <= xmax && temp >= xmin) { xmax = temp; // reduce right end of integration range } // Rectangular portion (if any) will always start at xmin double area = (xmid-xmin)*(ymax-ymin); // I used to know how to integrate stuff, but let's use trapezoidal approx: double h = xmax-xmid; // to start with, use a triangle: int k = 1; double area1 = 0; double area2 = trap(xmid,xmax,ymin); while(Math.abs(area2 - area1) > 1.e-5) { k = 2*k; h = h/2.; area1 = area2; area2 = 0; for (int i = 1; i <= k; i++) { double x1 = xmid+(i-1)*h; double x2 = xmid+i*h; area2 += trap(x1,x2,ymin); } } return area+area2; } public static double trap(double x1, double x2, double ymin) { double y1 = Math.sqrt(r*r-x1*x1)-ymin; double y2 = Math.sqrt(r*r-x2*x2)-ymin; return (y1+y2)/2.*(x2-x1); } }