Relax! It's Just a Game

Interview

Time limit1sMemory limit128 MB

Summary
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 AA goals and the other scored BB goals, it equals (A+BA)\binom{A+B}{A}. For each score, decide whether this number of possibilities equals the sum A+BA+B.

Input

The input consists of one or more test cases. Each test case is a single line with two natural numbers AA and BB (separated by one or more spaces) giving the first-half score. No team scores more than 1010 goals, so 0≤A,B≤100 \le A, B \le 10. Input ends with a line containing two values of −1-1, 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 AA and BB are the two scores and CC is their sum. If the number of possibilities is not equal to the sum, replace the = sign with !=.

Examples4

  1. Example 1

    Input
    2 1
    1 0
    -1 -1
    
    Expected output
    2+1=3
    1+0=1
    
  2. Example 2

    Input
    1 1
    3 1
    1 5
    -1 -1
    
    Expected output
    1+1=2
    3+1=4
    1+5=6
    
  3. Example 3

    Input
    2 2
    3 2
    0 0
    -1 -1
    
    Expected output
    2+2!=4
    3+2!=5
    0+0!=0
    
  4. Example 4

    Input
    0 1
    1 0
    0 2
    2 0
    -1 -1
    
    Expected output
    0+1=1
    1+0=1
    0+2!=2
    2+0!=2