Description

我是個超級電視迷,但是我不喜歡固定看一個頻道,我經常在不同頻道間轉來轉去。

我的狗咬壞了我的遥控器,現在數字鍵都不能用了,只剩兩個按鈕可以換頻道,一個往上切一個頻道 (△ 按鈕),一個往下切一個頻道 (▽ 按鈕)。這樣真的很煩,因為如果我要從頻道 3 換到頻道 9 我得按 6 次 △ 按鈕。

我的電視有 100 個頻道,號碼為 0 到 99。它們是循環的,也就是從 99 台再按一下 △ 就會回到第 0 台。同理,從第 0 台按一下 ▽ 就會回到 99 台。

幫我寫個程式,讓我輸入現在正在看的頻道和我要切過去的頻道,它便告訴我最少需要按幾次按鈕。

I’m a big fan of watching TV. However, I don’t like to watch a single channel; I’m constantly zapping between different channels.

My dog tried to eat my remote controller and unfortunately he partially destroyed it.

The numeric buttons I used to press to quickly change channels are not working anymore.

Now, I only have available two buttons to change channels: one to go up to the next channel (the △ button) and one to go down to the previous channel (the ▽ button). This is very annoying because if I’m watching channel 3 and want to change to channel 9 I have to press the △ button 6 times!

My TV has 100 channels conveniently numbered 0 through 99. They are cyclic, in the sense that if I’m on channel 99 and press △ I’ll go to channel 0. Similarly, if I’m on channel 0 and press ▽ I’ll change to channel 99.

I would like a program that, given the channel I’m currently watching and the channel I would like to change to, tells me the minimum number of button presses I need to reach that channel.

Input (From File: input.txt)

輸入含有多筆測資 (最多 200 筆)。

每筆測資含有兩個整數 a 與 b 於一行。a 是我現在看的頻道而 b 則是我要切過去的頻道 (0 ≤ a, b ≤ 99)。

最後一行有兩個 -1,請不要處理。

The input contains several test cases (at most 200).

Each test case is described by two integers a and b in a single line. a is the channel I’m currently watching and b is the channel I would like to go to (0 ≤ a, b ≤ 99).

The last line of the input contains two ‘-1’s and should not be processed.

Output (To File: output.txt)

對於每筆測資,輸出一個整數於一行 — 也就是我最少要按幾次按鈕才能切到新頻道。(記住,只有 △ 和 ▽ 兩個按鈕可用)。