No.1860 Magnets
タグ : / 解いたユーザー数 189
作問者 :
ぷら
shiomusubi496
Problem Statement
In the Shinpuro Kingdom, there are $2$ types of magnets: magnet $X$, whose $N$-pole side is red and whose $S$-pole side is blue, and magnet $Y$, whose $S$-pole side is red and whose $N$-pole side is blue.
Consider arranging all of the $A$ magnets $X$ and $B$ magnets $Y$ in a row. Here, adjacent magnets must be joined with opposite poles touching each other.
When looking at the colors of the magnets arranged in a row, what is the minimum number of places where the color changes?
Note that all of these magnets consist of the $2$ colors red and blue, and each has exactly one color boundary, in its middle.
(Original idea: Cyanmond)
Input
$A$ $B$
- $0 \leq A,B \leq 10^9$
- $A, B$ are integers
Output
Print the answer to the problem as a number on one line.
Sample
Sample 1
Input
3 4
Output
7
For example, they can be placed as follows.
In this case, there are $7$ color boundaries. It is impossible to have $6$ or fewer color boundaries, so print $7$.
Sample 2
Input
33 4
Output
65
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。