#K36202. Counting Perimeter Pillars
Counting Perimeter Pillars
Counting Perimeter Pillars
In this problem, you are given the dimensions of a rectangular garden with a length of N meters and a width of M meters. Pillars are to be placed around the perimeter of the garden at 1-meter intervals. Note that pillars at the corners are counted only once.
You need to compute the total number of pillars required. The result can be computed using the formula:
$$P = 2(N+1) + 2(M+1) - 4$$
where the term N+1
(or M+1
) represents the number of pillar positions along that side, and the four corner pillars are subtracted to avoid double-counting.
inputFormat
The input is given as a single line containing two space-separated integers N and M (1 ≤ N, M ≤ 104), representing the dimensions of the garden in meters.
outputFormat
Output a single integer representing the total number of pillars required to surround the garden.
## sample1 1
4