Решение проблемы HackerRank в C#: радиопередатчики Hackerland
Постановку задачи можно найти здесь: https://www.hackerrank.com/challenges/hackerland-radio-transmitters
Решение: https://gist.github.com/knsatishkumar/df1e058214a7cc2e8081c43655f1b3a1
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { string[] tokens_n = Console.ReadLine().Split(‘ ‘); int noOfHouse = Convert.ToInt32(tokens_n[0]); int range = Convert.ToInt32(tokens_n[1]); string[] x_temp = Console.ReadLine().Split(‘ ‘); int[] x = Array.ConvertAll(x_temp,Int32.Parse); noOfHouse = x.Max(); int towerCount = 1; int maxRange = range * 2 + 1; int noOfHousesLeft = noOfHouse — maxRange; while (noOfHousesLeft > maxRange) { towerCount++; noOfHousesLeft = noOfHousesLeft — maxRange; } if (noOfHousesLeft > 0) towerCount++; Console.WriteLine(towerCount); } }