CodechefSep 09, 2025

Chef and Wire Frames

Hazrat Ali

Codechef

Chef has a rectangular plate of length N cm and width M cm. He wants to make a wireframe around the plate. The wireframe costs X rupees per cm.

Determine the cost Chef needs to incur to buy the wireframe.

Input Format

  • First line will contain T, the number of test cases. Then the test cases follow.
  • Each test case consists of a single line of input, containing three space-separated integers N,M and X — the length of the plate, width of the plate, and the cost of frame per cm.

Output Format

For each test case, output in a single line, the price Chef needs to pay for the wireframe.

Constraints

  • 1≤T≤1000
  • 1≤N,M,X≤1000

Sample 1:

Input
3
10 10 10
23 3 12
1000 1000 1000
Output
 
400
624
4000000

Solution

#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int m, n, q;
        cin >> m >> n >> q;
        int sum = m * 2 + n * 2;
        cout << sum * q << endl;
    }
    return 0;
}




Comments