Editorial for TLE '16 Contest 7 P1 - Math Helper
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
This problem requires string processing and the ability to implement conditions.
A simple way to process the string is to take only the expression with x
without y =
and to strip the string of surrounding whitespace (just to be safe - the test data shouldn't actually contain whitespace after the expressions). We can use built-in functions such as find()
, substr()
, and atoi()
in C++ instead of using many loops to get the values of and easily.
Afterward, we simply have to implement the simplifying conditions given in the problem statement. It is recommended to test the conditions in order of decreasing priority. For example, first check if , then if , etc.
Time Complexity:
Comments