#C1039. Minimal Highway Construction Cost
Minimal Highway Construction Cost
Minimal Highway Construction Cost
Given two positive integers n
and k
, representing the number of cities and a cost multiplier respectively, your task is to compute the minimal cost to construct highways such that every pair of cities is directly connected. Since every highway between two distinct cities costs k
and there are \(\frac{n(n-1)}{2}\) highways in a complete network, the total cost is given by the formula:
$$Cost = k \times \frac{n(n-1)}{2}$$
Read the input from standard input and output the computed cost to standard output.
inputFormat
The input consists of a single line with two space-separated integers: n
(the number of cities) and k
(the cost multiplier).
outputFormat
Output a single integer, which is the minimal cost to construct all the required highways.
## sample3 1
3