Здравейте,
Моля за съдействие с тази задача. Опитвам някакви решения, но не стигам до никъде. Ето го условието.
Above the Main Diagonal
Description
You are given a number N
. Using it, create a square matrix of numbers, formed by powers of 2 and find the sum of the numbers above the main diagonal, excluding the diagonal itself.
Input
Read from the standard input.
- On the first line, read the number
N
- the number of rows and columns.
Output
Print to the standard output.
- On a single line print the sum of the numbers above the main diagonal excluding the diagonal.
Constraints
-
N
can get as big as30
.
Input
4
Output
70
Explanation
With N
equal to 4, we will have a matrix that looks like this:
1 2 4 8
2 4 8 16
4 8 16 32
8 16 32 64
Благодаря предварително.