Air Conditioner
InterviewTime limit2sMemory limit1024 MB
Given the current room temperature, a target temperature, and one of four AC modes, output the temperature after one hour of operation.
- Level
Easy2 of 10
- Topics
- Implementation, Simulation, Math, Brute force
- Solved
- No attempts yet
Problem
A new type of air conditioner was installed in the office where the programmer Pyotr works. This air conditioner is notable for being especially simple to control. It has only two adjustable parameters: the desired temperature and the operating mode.
The air conditioner can operate in the following four modes:
- «freeze» — cooling. In this mode the air conditioner can only lower the temperature. If the room temperature is already at most the desired temperature, it turns off.
- «heat» — heating. In this mode the air conditioner can only raise the temperature. If the room temperature is already at least the desired temperature, it turns off.
- «auto» — automatic mode. In this mode the air conditioner can either raise or lower the room temperature to the desired temperature.
- «fan» — ventilation. In this mode the air conditioner only ventilates the air and does not change the room temperature.
The air conditioner is powerful enough that, when set to the correct operating mode, it brings the room temperature to the desired temperature within one hour.
Write a program that, given the room temperature troom, the desired temperature tcond set on the air conditioner, and the operating mode, determines the temperature that will be established in the room after one hour.
Input
The first line of the input file contains two integers troom and tcond separated by exactly one space (–50 ≤ troom ≤ 50, –50 ≤ tcond ≤ 50).
The second line contains a single word written in lowercase Latin letters: the operating mode of the air conditioner.
Output
The output file must contain a single integer: the temperature that will be established in the room after one hour.