Answer to Question #281634 in C for Rahul Sigh

Question #281634

A university's library has been having electricity issues and students have been struggling to study during the night.


Each light source can illuminate a circle with a radius of r, and there are n tables in the library and the ith table is positioned at point (xi, yi). You have to help the university find the minimum number of light sources (k), such that each table is illuminated by at least 1 light source.



Input format


• The first line contains integers n and r respectively.


• In each of the next n lines, there are two integers representing xi and yi respectively that display the position of the ith table.


Output format


• In the first line of output, print an integer k that represents the number of light sources.



For Full Instructions and Question Please Use Those Images as reference... Please help


https://drive.google.com/file/d/1wWA7nKnFWaG5XgtzzLPymfbuqiIf7WH8/view?usp=sharing
1
Expert's answer
2021-12-21T06:17:35-0500
#include <bits/stdc++.h>
using namespace std;


int main()
{
    int n,r,count = 0;
    
    cin>>n>>r;
    
    int x[n], y[n];
    
    for (int i = 0; i<n; i++)
    {
        cin>>x[i]>>y[i];
        
        if (abs(x[i] - y[i]) == r)
        {
            count += 1;
            cout<<count<<endl;
            cout<<x[i]<<" "<<y[i]<<endl;
        }
        else
        {
            count += 0;
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS