fbinnzhivko

04.00 Teleport Points

Apr 15th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         string[] A = Console.ReadLine().Split();
  7.         string[] B = Console.ReadLine().Split();
  8.         string[] C = Console.ReadLine().Split();
  9.         string[] D = Console.ReadLine().Split();
  10.  
  11.         double radius = double.Parse(Console.ReadLine());
  12.         double step = double.Parse(Console.ReadLine());
  13.  
  14.         double Dx = double.Parse(D[0]); double Bx = double.Parse(B[0]);
  15.         double Dy = double.Parse(D[1]); double By = double.Parse(B[1]);
  16.         double Ax = double.Parse(A[0]); double Cx = double.Parse(C[0]);
  17.         double Ay = double.Parse(A[1]); double Cy = double.Parse(C[1]);
  18.  
  19.         //Console.WriteLine("{0} {1} {2} {3}", Ax, Ay, Bx, By);
  20.         //Console.WriteLine("{0} {1} {2} {3}", Dx, Dy, Cx, Cy);
  21.        
  22.         double count = 0;
  23.  
  24.         for (double y = Ay; y < Cy; y += step)
  25.         {
  26.             for (double x = Dx; x < Bx; x += step)
  27.             {
  28.                 bool isPodoubleInCircle = x * x + y * y < radius * radius;
  29.                 bool isInsideTheRectangle = (x >= Ax && x < Bx) && (y < Cy && y > By);
  30.  
  31.                 if (isPodoubleInCircle && isInsideTheRectangle)
  32.                 {
  33.  
  34.                     count++;
  35.                 }
  36.             }
  37.         }
  38.         Console.WriteLine(count);
  39.     }
  40. }
Add Comment
Please, Sign In to add comment