Now using Pythagorean theorem find if a cell touches or within any circle or not .
for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int p = 0 ; p < k ; p ++ ) { if ( sqrt ( ( pow ( ( X [ p ] - 1 - i ) , 2 ) + pow ( ( Y [ p ] - 1 - j ) , 2 ) ) ) <= r ) { rect [ i ] [ j ] = -1 ; } } } }