CWIREFRAME - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: S. Manuj Nanthan
Preparer: Mradul Bhatnagar
Testers: Satyam, Jatin Garg
Editorialist: Nishank Suresh

DIFFICULTY:

383

PREREQUISITES:

None

PROBLEM:

Chef has a rectangular plate of length N\ cm and width M\ cm. He wants to make a wireframe around the plate that costs X rupees per cm. What will the total cost be?

EXPLANATION:

The perimeter of the plate is 2\cdot(N+M) \ cm. Each centimeter of this costs rupees X, so the final cost is X\cdot 2\cdot(N+M) rupees.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    n, m, x = map(int, input().split())
    print(2*x*(n+m))