Relax! It's Just a Game
InterviewTime limit1sMemory limit128 MB
For each score (A, B), check whether the binomial coefficient C(A+B, A) equals the sum A+B, and print the comparison.
- Level
Easy3 of 10
- Topics
- Math, Combinatorics, Implementation, Brute force
- Solved
- No attempts yet
Problem
- You: What's the score? Did I miss much?
- Me: It's 2-1 for elAhli and the second half just started. The first half was quite boring.
- You: Who scored first, elAhli or ezZamalek?
- Me: What difference does it make?
- You: A big difference! I can predict the outcome of the match if I know the order in which the goals were scored in the first half.
- Me: What do you mean?
- You: It's 2-1 for elAhli, right? One of three things could have happened: elAhli scored twice and then ezZamalek scored; or elAhli scored, then ezZamalek, then elAhli again; or ezZamalek scored first and then elAhli scored twice.
- Me: So?!! I still don't see what difference it makes. It's still 2-1 for elAhli! Why don't you relax and let us watch the game in peace?
- You: You don't understand! I believe the probability of who will win depends on the order in which the goals were scored. Now I have to analyze 3 possibilities.
- Me: And what if the score were 3-2? What would you do then?
- You: I would have to work through 5 different possibilities. Right?
- Me: Of course not! The number of possibilities isn't always equal to the sum.
- You: Can you tell me when it is equal to the sum?
- Me: You're a programmer. Why don't you write a program that counts the number of possibilities and compares it to the sum?
- You: I don't have time; I want to watch the match. Besides, I have nine other problems to worry about.
- Me: I'll give you a hint. The number of possibilities equals the sum only when one of the teams scored a certain number of goals.
Given a first-half score, the number of possibilities is the number of distinct orders in which the goals could have been scored: if one team scored goals and the other scored goals, it equals . For each score, decide whether this number of possibilities equals the sum .
Input
The input consists of one or more test cases. Each test case is a single line with two natural numbers and (separated by one or more spaces) giving the first-half score. No team scores more than goals, so . Input ends with a line containing two values of , which is not part of the test cases.
Output
For each test case, if the number of possibilities equals the sum, print:
A+B=C
where and are the two scores and is their sum. If the number of possibilities is not equal to the sum, replace the = sign with !=.