Problem Statement |
| | John and Brus are bored.
They have n+m common friends.
The first n of them are bored and other m are not.
John chooses the j-th (1-based) friend for a talk.
If the friend is not bored, he becomes bored after the talk.
Brus does the same with the b-th (1-based) friend.
Note that John and Brus can't choose the same friend.
You have to find the number of bored friends after the talks.
|
| |
Definition |
| | | Class: | TheBoredomDivTwo | | Method: | find | | Parameters: | int, int, int, int | | Returns: | int | | Method signature: | int find(int n, int m, int j, int b) | | (be sure your method is public) |
|
| |
|
| |
Constraints |
| - | n will be between 1 and 47, inclusive. |
| - | m will be between 1 and 47, inclusive. |
| - | j will be between 1 and n+m, inclusive. |
| - | b will be between 1 and n+m, inclusive. |
| - | j and b will be different. |
| |
Examples |
| 0) | |
| | | Returns: 2 | | The first friend is already bored and the second friend becomes bored after the talk with Brus. |
|
|
| 1) | |
| | | Returns: 2 | | Here John and Brus choose two friends that are already bored. |
|
|
| 2) | |
| | | Returns: 3 | | All the friends become bored. |
|
|
| 3) | |
| | |