#P6343. [CCO 2017] 矩形帝国的霸业

[CCO 2017] 矩形帝国的霸业

Description

A long, long time ago, the Rectangular Empire ruled the Cartesian Continent. The empire was rich and powerful, and through endless wars and conquests, its territory expanded day by day.

The Rectangular Empire used a rectangular district system. These districts all satisfy three special rules.

  1. The empire’s territory is divided into districts, and every piece of land belongs to one and only one district.

  2. When viewed on the map, each district must be a rectangle, and the longer side must be twice the length of the shorter side.

  3. The side lengths of each district must be integers, measured in ΞΞ (ΞΞ is the empire’s unit of measurement).

When the empire was first founded, it consisted of a single district. From then on, to expand its land, the empire continuously conquered neighboring areas. Each time the empire gained control of a new area, it always created a separate new district that occupies all of the newly acquired land. This means the empire only cares about the geometric properties of the land it wants to conquer. You may assume that no two conquests happen at the same location.

The empire can expand only by adding new districts. Also, once a district is added, it is never modified or merged with another one.

The final rule of the Rectangular Empire is to ensure that the empire’s overall shape is a rectangle. However, the aspect ratio of this large rectangle does not need to be 2:12:1.

The empire has length nn and width mm (in units of ΞΞ). Your task is to estimate the number of districts the empire can have for an n×mn \times m empire. Among all possible cases, what are the minimum and maximum possible numbers of districts?

Input Format

The input contains a single line with two integers n,mn, m.

Output Format

Output a single line with two integers. The first is the minimum number of districts, and the second is the maximum number of districts.

10 6
5 8

Hint

Sample Explanation

Constraints and Notes

This problem uses bundled testdata with a total of 33 subtasks.

  • Subtask 1 (20 points): 1n,m1031 \le n,m \le 10^3.
  • Subtask 2 (32 points): 1n,m1061 \le n,m \le 10^6.
  • Subtask 3 (48 points): 1n,m1081 \le n,m \le 10^8.

For all testdata, it is guaranteed that 1n,m1081 \le n,m \le 10^8.

Source: CCO 2017 Day 1 “Cartesian Conquest”.

Note: This translation is from LOJ.

Translated by ChatGPT 5