#P1984. [SDOI2008] 烧水问题

[SDOI2008] 烧水问题

Description

A total mass of 1 kg1\ \rm kg of water is divided into nn cups, each containing (1/n) kg(1/n)\ \rm kg of water, all initially at 00 degrees. We need to bring every cup of water to a boil. We may heat any cup. The energy required to raise one cup’s temperature by tt degrees is (4200×t/n)J(4200\times t/n)\rm J, where J\rm J is the energy unit "joule". Once a cup’s temperature reaches 100100 degrees, it cannot be heated further; at that point we consider this cup to have been boiled. Clearly, if we simply boil the cups one by one directly, the total energy required is (4200×100)J(4200\times 100)\rm J.

During the process, we may perform heat transfer between any two cups at different temperatures at any time. Heat can only flow from the hotter cup to the cooler cup. Since the two cups have equal mass, after a heat transfer operation, the temperature decrease of the originally hotter cup always equals the temperature increase of the originally cooler cup.

Heat transfer stops immediately once the two cups reach the same temperature.

To simplify the problem, assume:

  1. When neither heating nor heat transfer is being performed, water temperature does not change.
  2. All energy spent on heating is absorbed by the water; the cup absorbs no energy.
  3. Heat transfer always occurs through the cup walls; the nn cups of water never mix.
  4. Heat transfer conserves energy and has no loss.

In this problem, it is only required that each cup be brought to a boil at least once; it is not required that every cup ends at 100100 degrees. For example, we can boil two cups as follows: first heat one cup to 100100 degrees, costing (4200×100/2)J(4200\times 100/2)\rm J, then perform heat transfer between the two cups until both are at 5050 degrees, and finally heat the cup that was not previously brought to 100100 degrees up to 100100 degrees, costing (4200×50/2)J(4200\times 50/2)\rm J. At this point, both cups have been boiled; the current temperatures are one at 100100 degrees and one at 5050 degrees. The total energy spent is (4200×75)J(4200\times 75)\rm J, which is 25%25\% less than the (4200×100)J(4200\times 100)\rm J required by direct boiling.

Your task is to design an optimal sequence of operations that minimizes the total energy required to ensure that all nn cups are each boiled at least once.

Input Format

One line containing an integer nn.

Output Format

Output the minimal total energy required to boil all nn cups at least once, in J\rm J, rounded to two decimal places.

2
315000.00

Hint

Constraints

For all testdata, 1n30000001 \le n \le 3000000.

Translated by ChatGPT 5