#P5441. Rebuilding X Kingdom
Rebuilding X Kingdom
Rebuilding X Kingdom
X Country has suffered from an unprecedented earthquake leaving the nation shattered. In order to help its people heal and ensure the survival of the country, the king of X Country has decided to rebuild the nation by constructing n cities. Note that since the king has an affinity for odd numbers, n is an odd integer (with n ≥5 since 4 core cities must be chosen).
After constructing the cities, every pair of cities is to be connected by a road, making a total of \( \frac{n(n-1)}{2} \) roads. Owing to limited funds, after building the cities the budget is sufficient to build at most n bidirectional roads; the remaining roads must be built as one‐way roads. The cost for building a one‐way road is independent of its direction, so you can assign any direction to them.
Once reconstruction is complete, the king will select 4 cities to serve as the country’s core. To stimulate development, it is required that for every pair of these 4 core cities, there exists a route between them that does not pass through any non‐core city (i.e. the subgraph induced by these 4 cities must be strongly connected).
Your task is to produce a road construction scheme that maximizes the number of ways to choose 4 core cities such that the above connectivity condition is satisfied. It can be shown that the optimal scheme makes every 4‐subset of cities valid; hence, the maximum number of valid choices is given by the binomial coefficient \( \binom{n}{4} \), which can be computed as:
[ \frac{n(n-1)(n-2)(n-3)}{24} ]
Given the odd integer n as input, output the maximum number of valid 4-core-city selections.
inputFormat
The input consists of a single line containing one odd integer n (n ≥5), representing the number of cities.
outputFormat
Output one integer: the maximum number of valid selections of 4 core cities under an optimal road building scheme.
sample
5
5