OlveraeUNSW
Back to problems
COMP2521

Complexity: Multiplications in Matrix Multiply

Complexity: scalar multiplications in N×N matrix multiply

Multiplying two N×N matrices with the naive triple-loop algorithm: how many scalar multiplications does it do? Read N and print that count.

Complete matMultCount.

Key derivation: the result matrix has N×N entries; each entry is a row-dot-column needing N multiplications. So the total is N × N × N = N³. That is the origin of matrix multiply's O(n³). For N = 3 it is 27 (the answer to 21T3 Q1).

Input

  • One line: integer N (0 ≤ N ≤ 1000).

Output

  • One line: the number of scalar multiplications, N³.

Example: input 3 -> 27.

Samples

stdin
3
expected
27
stdin
2
expected
8
c-dcc
14