Maximum number of ones in a N * N matrix with given constraints | Function that returns the maximum number of ones ; Minimum number of zeroes ; Totol cells = square of the size of the matrices ; Initialising the answer ; Initialising the variables
def getMaxOnes ( n , x ) : NEW_LINE INDENT zeroes = ( int ) ( n / x ) ; NEW_LINE zeroes = zeroes * zeroes ; NEW_LINE total = n * n ; NEW_LINE ans = total - zeroes ; NEW_LINE return ans ; NEW_LINE DEDENT n = 5 ; NEW_LINE x = 2 ; NEW_LINE print ( getMaxOnes ( n , x ) ) ; NEW_LINE