Mint Choco
InterviewTime limit1sMemory limit1024 MB
Given a chain of integer multiplications and divisions, decide whether the overall value is an integer or a non-integer rational.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Hash map, Implementation
- Solved
- No attempts yet
Problem
Sangwon picks his dessert in a very unusual way.
Sangwon writes an arbitrary expression made up only of multiplications and divisions of integers. If the result is an integer, he eats "mint choco"; if the result is a rational number that is not an integer, he eats "toothpaste".
Given the expression Sangwon wrote, determine which dessert he will eat.
Input
The first line gives , the number of numbers in the expression. ()
The second line gives the expression. The expression consists of integers and operators (*, /) separated by spaces. Integers and operators alternate, and the expression always starts and ends with an integer. Every integer in the expression is between and , inclusive.
Only valid expressions are given, and no case divides by .
Output
If the dessert Sangwon picked is "mint choco", print mint chocolate; if it is "toothpaste", print toothpaste.