[Huawei OD Unified Exam B Paper | 100 points]Matrix maximum value (C++ Java JavaScript Python)

topic description

Given an N*N two-dimensional matrix containing only 0 and 1, please calculate the maximum value of the two-dimensional matrix. The calculation rules are as follows:

1. The elements in each row form a binary number in the order of subscripts (the larger the subscript, the lower the order), and the value of the binary number is the value of the row. The sum of the row values ​​of a matrix is ​​the value of the matrix.
2. It is allowed to change the position of each element in the row by moving the elements of each row to the left or to the right.

For example:
[1,0,1,1,1] moves 2 bits to the right as a whole to become [1,1,1,0,1], the binary number is 11101, and the value is 29.
[1,0,1,1,1] moves 2 bits to the left as a whole to become [1,1,1,1,0], the binary number is 11110, and the value is 30.

enter description

1. The first line of input is a positive integer, recording the size of N, 0 < N <= 20.
2. lose

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/130926377