- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program to find out if k monitoring stations are enough to monitor particular points in Python

Suppose there is a sensor module that can monitor its nearby environment up to a radius of r. There are some things in the lattice point of the module's monitoring circle that needs to be monitored. So, k number of low-powered modules are placed so that they can monitor only those specific points. Given the square of the radius and k number of low-powered modules, we shall have to find out if the points can be monitored correctly. We return true if monitoring is possible, otherwise, we return false.

So, if the input is like square of radius (j) = 4, number of monitoring points(k) = 3, then the output will be False

If j = 4, there are 4 points on the circumference of the monitoring circle; that are: (0,2), (0,-2), (2,0), and(-2,0). So, if we introduce three new monitoring stations, we cannot monitor the points fully.

To solve this, we will follow these steps −

- square_set := a set containing square of values up to 44721
- i := 0
- res := 0
- while i <(j ^ 0.5), do
- if (j - i ^ 2) is present in square_set, then
- res := res + 1

- i := i + 1

- if (j - i ^ 2) is present in square_set, then
- res := res * 4
- if k >= res, then
- return True

- otherwise,
- return False

## Example

Let us see the following implementation to get better understanding −

square_set = set([z ** 2 for z in range(44722)]) def solve(j, k): i = 0 res = 0 while i < (j ** 0.5): if j - i ** 2 in square_set: res += 1 i += 1 res *= 4 if k >= res: return True else: return False print(solve(4, 3))

## Input

4, 3

## Output

False

- Related Questions & Answers
- Program to Find Out the Maximum Points From Removals in Python
- Program to check if number of compass usage to get out of a maze is enough in Python
- Program to find out if two expression trees are equivalent using Python
- Program to Find Out the Points Achievable in a Contest in Python
- C++ Program to check k rupees are enough to reach final cell or not
- Program to find out the maximum points collectable in a game in Python
- Program to Find Out the Largest K-Divisible Subsequence Sum in Python
- C++ Program to find out if a round trip is possible from a particular city
- Program to Find Out the Probability of Having n or Fewer Points in Python
- Program to find out if we win in a game in Python
- Python Program to find out how many cubes are cut
- Check if the given number K is enough to reach the end of an array in Python
- Program to check if three points are collinear in C++
- Python – Check if particular value is present corresponding to K key
- Program to find out the letter at a particular index in a synthesized string in python