ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

USU Internal Contest March'2002

About     Problems     Submit solution     Judge status     Standings
Contest is over

A. Horns and Hoofs

Time limit: 0.25 second
Memory limit: 64 MB
The famous venturer Ostap B. decided to organize a firm "Horns & Hoofs" which will produce horns and hoofs. First of all, Ostap has studied the market, the manufacturing process, and the local conditions.
The calculations showed that each horn would give a profit of A roubles and each hoof would bring B roubles. It must be taken into account that there are similar products in the market already and that horns and hoofs are in a sense interchangeable. Therefore the total amount of produced goods must not exceed K pieces each month, otherwise the excess will not be sold.
Besides, Ostap B. knows that the local racketeers fight monopolism and collect each month for each type of goods a "tax" which is equal (in roubles) to the square of the produced amount. For example, if the firm has produced two horns and three hoofs, then they must pay 4+9=13 roubles.
Having heard about the success of students of the Department of Mathematics and Mechanics in the All-Russian finals of business game Nixdorff Delta, Ostap appealed to the dean's office. He asked to calculate the optimal production volumes for his new firm. The dean is sure that his students will cope with this task.


The first line contains real numbers A and B (−10000 ≤ A,B ≤ 10000) with a two fractional digits precision. These numbers are the profits (in roubles) given by each horn and by each hoof respectively.
The next line contains an integer K which is the maximal number of goods that could be sold each month (1 ≤ K ≤ 10000).


You should output at the first line the maximal possible profit with a two fractional digits precision. The next line should contain the optimal production volumes.
If there are several possible answers, you should output the one with the least amount of horns, and if there is still a tie with the least amount of hoofs.


34.20 61.70
16 29
Problem Author: Magaz Asanov
Problem Source: USU Internal Contest, March 2002
To submit the solution for this problem go to the Problem set: 1200. Horns and Hoofs