Problem A
Around the Table
Emilia and her brother Alex meet up with a lot of friends in the park to play table tennis together. Since there is only one table, they play round-the-table which is everybody’s favourite.
The rules are simple: There are $\ell \geq 2$ kids queueing up on the left side and $r \geq 1$ kids queueing up on the right side of the table. The first kid on the left side starts with the ball. Whoever has the ball hits it over the net onto the opposite side and runs around the table to join the queue at the opposite side. This is repeated until the first mistake.
![\includegraphics[width=\textwidth ]{sample}](/problems/aroundthetable/file/statement/en/img-0001.png)
Emilia, Alex, and their friends play this game all the time and are so good that they can go on almost forever without making any mistake. After some time, Emilia notices that she has never faced Alex, meaning that they have never been at the front of opposite queues at the same time. She wonders if this will ever happen in this round. Curious about this, she starts keeping track which pairings have already faced each other.
How many different pairings has she counted after the ball went over the net $10^{10^{100}}$ times?
Input
The input consist of:
-
One line with two integers $\ell $ and $r$ ($2 \leq \ell \leq 10^{9}$ and $1 \leq r \leq 10^{9}$), the number of players on the left and right side of the table, respectively.
Output
Output the number of different pairings Emilia counts.
Sample Input 1 | Sample Output 1 |
---|---|
2 2 |
6 |
Sample Input 2 | Sample Output 2 |
---|---|
2 3 |
10 |
Sample Input 3 | Sample Output 3 |
---|---|
3 2 |
5 |
Sample Input 4 | Sample Output 4 |
---|---|
5 2 |
14 |