Bradara

Задача 4 30 08 2015

Nov 15th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Teleport_Points
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var point1 = Console.ReadLine().Split(' ');
  14.             var point2 = Console.ReadLine().Split(' ');
  15.             var point3 = Console.ReadLine().Split(' ');
  16.             var point4 = Console.ReadLine().Split(' ');
  17.             var radius = double.Parse(Console.ReadLine());
  18.             var step = double.Parse(Console.ReadLine());
  19.  
  20.             var count = 0;
  21.             //down left side.          
  22.             count +=CalculatePoints(point1[0], point1[1], radius, step);
  23.             count +=CalculatePoints(point2[0], point2[1], radius, step);
  24.             count +=CalculatePoints(point3[0], point3[1], radius, step);
  25.             count +=CalculatePoints(point4[0], point4[1], radius, step);
  26.             Console.WriteLine(count);
  27.  
  28.         }
  29.  
  30.         private static int CalculatePoints(string x, string y, double radius, double step)
  31.         {
  32.             var pointX = Math.Abs(double.Parse(x));
  33.             var pointY = Math.Abs(double.Parse(y));
  34.             var count = 0;
  35.             for (double i = 0; i < radius; i+=step)
  36.             {
  37.                 for (double k = step; k < radius; k+=step)
  38.                 {
  39.                     if (i*i +k*k <radius*radius)
  40.                     {
  41.                         if (pointX<=i||pointY<=k)
  42.                     {
  43.                         continue;
  44.                     }
  45.                     count++;
  46.  
  47.                     }                  
  48.                    
  49.                 }
  50.             }
  51.             Console.WriteLine(count);
  52.             return count;          
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment