Composite Functions for the Chairman
InterviewTime limit1sMemory limit1024 MB
Given an integer quadratic f and a linear g, count the x-values where f(g(x)) equals g(f(x)) and report the matching phrase.
- Level
Medium4 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
The chairman has a difficult personality. When he is pleased, he says "Nice" or "Go ahead". When he is not pleased, he says "Remember my character". If someone crosses his line, he rebukes them mercilessly with "Head on".
His request is to build a composite function from two polynomials and .
Let and . The highest degree of is at most 2, and the highest degree of is at most 1. The chairman reacts to the number of points where and meet. If there are infinitely many points, he says "Nice". If there are two, he says "Go ahead". If there is one, he says "Remember my character". If there are none, he says "Head on".
The number of meeting points can be found by counting the points where meets the x-axis.
Input
The first line contains the coefficient of the term, the coefficient of the term, and the constant term of , separated by spaces, in that order. The second line contains the coefficient of the term and the constant term of , separated by spaces, in that order.
All coefficients and constant terms are integers from -20 to 20.
Output
Print one of "Nice", "Go ahead", "Remember my character", or "Head on", depending on the number of points where the two functions meet.