#P6269. Maximum Number of Bridges

    ID: 19487 Type: Default 1000ms 256MiB

Maximum Number of Bridges

Maximum Number of Bridges

In a futuristic aerial city, there are many small islands (districts). Bridges can be built between two islands, but there is a rule: if there is a bridge between AA and BB, and a bridge between BB and CC, then a bridge between AA and CC is not allowed. In other words, for any three islands, it is forbidden to have bridges built between every pair (i.e. a triangle is not allowed). Under this constraint, your task is to build as many bridges as possible between the islands without considering any spatial issues.

Note: This problem is equivalent to finding the maximum number of edges in a triangle-free graph with nn vertices. By Mantel's theorem, the maximum number of edges is ( \lfloor \frac{n^2}{4} \rfloor ).

inputFormat

The input consists of a single integer nn (1n1091 \le n \le 10^9) representing the number of islands.

outputFormat

Output a single integer denoting the maximum number of bridges that can be constructed under the given constraints.

sample

1
0