luogu#P9581. 「MXOI Round 1」宝箱

    ID: 9087 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>模拟数学洛谷原创O2优化洛谷月赛

「MXOI Round 1」宝箱

Problem Description

Little C likes collecting treasure chests in a game called Yuanshen (pinyin).

Now, Little C is on a number line, and he is at the origin of the number line.

At the same time, there are two treasure chests on this number line, with coordinates aa and bb.

As long as Little C moves to the position of a treasure chest, we consider that Little C has collected this treasure chest. In particular, if Little C is initially at the position of a treasure chest, then he can collect this treasure chest directly. If the two treasure chests are at the same position, then he can collect both treasure chests at the same time.

Each time, Little C can move 1 unit length along the positive direction or the negative direction of the number line. Little C wants to know: to collect both treasure chests, what is the minimum number of moves needed?

Input Format

Two integers a,ba,b.

Output Format

One integer, representing the minimum number of moves Little C needs to collect both treasure chests.

1 -1
3
-5 0
5
51 -154
256

Hint

Sample Explanation #1.

Little C can first move 11 time in the negative direction of the number line, and then move 22 times in the positive direction.

It can be proven that Little C needs at least 33 moves.

Sample Explanation #2.

Little C can directly move 55 times in the negative direction of the number line.

It can be proven that Little C needs at least 55 moves.

Constraints.

For 100%100\% of the testdata, a,b200\vert a\vert,\vert b\vert \le 200.

Test Point ID Special Property
131\sim3 Guaranteed that a,b1\vert a\vert,\vert b\vert \le 1
464\sim6 Guaranteed that ab=0ab=0
7107\sim10 None

Translated by ChatGPT 5