#MTH000000026. Ba gia đình (Three Families)
Ba gia đình (Three Families)
Three Families
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Families A, B and C share a garden. Last week family C was away, so A and B did all the work. Family A worked for hours and family B worked for hours. Both families work at the same speed.
When C returns, it pays a total of dollars to A and B to compensate for the work that C should have done. The money must be split according to the work each family did beyond its fair one-third share, not merely in proportion to the hours A and B worked.
Compute the amount received by family A. The input guarantees that both A and B receive nonnegative integer amounts.
Input
One line contains three integers , , .
Output
Print the number of dollars received by family A.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): and is divisible by .
- Subtask 3 (50%): Full constraints: , .
Examples
Input
5 4 90
Output
60
Explanation
A and B worked a total of
hours. A fair three-way share is hours per family.
A worked hours beyond its share, while B worked extra hour. Thus the dollars compensate excess hours, which is dollars per excess hour. Family A receives
dollars, so the program prints 60.