ANARC08E - Relax! It is just a game

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: Big difference! I can predict the outcome of the match if I knew the order of which 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 two goals then ezZamalek scored; Or, elAhli scored its first goal, then ezZamalek, then elAhli again; Or, ezZamalek scored first, then elAhli scored its two goals.

Me: So?!! I still don't understand what difference does that make? It's still 2-1 for elAhli! Why don't you just relax and let us continue watching the game in peace.

You: You don't understand!! I believe the probability of who'll win depends on the order of how goals were scored. Now I have to predict the outcome for 3 possibilities.

Me: And what if the score was 3-2? What would you have done then?

You: I would have to work for 5 different possibilities. No?

Me: Of course not! The number of possibilities isn't always equal to the sum.

You: Can you tell me when will it be equal to the sum?

Me: You're a programmer, why don't you write a program that counts the number of possibilities and compare it to the sum?

You: I don't have the time, I want to watch the match. Besides, I have nine other problems to worry about.

Me: I'll give you a hint. The possibilities will be equal to the sum only if one of the teams scored a certain number of goals.


Your program will be tested on one or more test cases. Each test case specifies two natural numbers (A and B ) (separated by one or more spaces) representing the score of the first half. No team will be able to score more than 10 goals. The last line of the input file contains two -1's (which is not part of the test cases.)


Format For each test case where the number of possibilities is equal to the sum, print:


Where A and B are as above and C is their sum. If the number of possibilities is not equal to the sum, replace the '=' sign with '!=' (without the quotes.)


2 1
1 0
-1 -1


hide comments
Egor: 2011-02-03 14:33:53

Chandra Sekar, thank you =)
I have not read the problem, only your example =)

Last edit: 2011-02-03 14:34:19
VinyleEm: 2010-12-21 02:22:58

Could the problem setters please format the input data set neatly before posting it? That's way better than cluttered input which makes it difficult to read in certain languages

Prashant Gupta: 2010-09-01 21:47:31

And I am getting SIGSEG . . Segmentation fault while its running perfectly fine on my comp

S.Udhayakumar: 2010-07-19 14:19:44

3 4
5 7
8 9
9 1
10 10
10 0
0 1
-1 -1

Still answer wrong can any body explain me?

Knight: 2010-07-10 08:12:35

total possibilities any ways is i think
{(m+n)!/m!*n!} and when n=1 then it comes out to be m+1 and == m+1

Sudeshna: 2010-06-28 17:03:31

this is quite a stupid problem. There is no need to calculate total no. of possibilities. And example i/p o/p does not show that clearly!

Shahriar Ameri: 2010-04-08 05:07:42

Eisenstein-Berniger Theorem ...

Last edit: 2010-04-08 05:08:13
Brian Bi: 2009-08-03 00:40:38

Why do you need to know the number of test cases? Does your program read in the entire input file and store it in an array? You shouldn't be doing that!

Added by:Ahmed Aly
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ANARC 2008