Canadian Computing Competition: 2021 Stage 1, Junior #1
At sea level, atmospheric pressure is kPa and water begins to boil at . As you go above sea level, atmospheric pressure decreases, and water boils at lower temperatures. As you go below sea level, atmospheric pressure increases, and water boils at higher temperatures. A formula relating atmospheric pressure to the temperature at which water begins to boil is
where is atmospheric pressure measured in kPa, and is the temperature at which water begins to boil measured in .
Given the temperature at which water begins to boil, determine atmospheric pressure. Also determine if you are below sea level, at sea level, or above sea level.
Note that the science of this problem is generally correct but the values of and kPa are approximate and the formula is a simplification of the exact relationship between water's boiling point and atmospheric pressure.
The input is one line containing an integer where and . This represents the temperature in at which water begins to boil.
The output is two lines. The first line must contain an integer which is atmospheric pressure measured in kPa. The second line must contain the integer -1, 0, or 1. This integer represents whether you are below sea level, at sea level, or above sea level, respectively.
When , we can substitute into the formula and get which equals . Since kPa is less than kPa, you are above sea level.
When , we can substitute into the formula and get which equals . Since kPa is greater than kPa, you are below sea level.
No comments yet. Be the first to comment!