An IP address is a formatted 32-bit unsigned integer where each group of 8 bits is printed as a decimal number and the dot character '.' splits the groups.
For example, the binary number 00001111 10001000 11111111 01101011 formatted as an IP address would be "15.136.255.107".
A CIDR block is a format used to denote a specific set of IP addresses. It consists of a base IP address, followed by a slash, followed by a prefix length k. The addresses it covers are all the IPs whose first k bits are the same as the base IP address.
For example, "123.45.67.89/20" is a CIDR block with a prefix length of 20. Any IP address whose binary representation matches 01111011 00101101 0100xxxx xxxxxxxx (where x can be either 0 or 1) is covered by this CIDR block.
Given a start IP address ip and the number of IP addresses we need to cover n, return the shortest list of CIDR blocks that covers all IP addresses in the inclusive range [ip, ip + n - 1] exactly. No other IP addresses outside of the range should be covered.
Input & Output
Constraints
- ip is a valid IPv4 address
- 1 ≤ n ≤ 1000
- The range [ip, ip + n - 1] will not overflow