拨号锁
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
题目描述
高度重视安全的高桥,决定为自己的方案安上新的锁。
该锁是一种拨号锁,上面有显示一个数字和两种按钮(红色和蓝色)的显示器。按下红色按钮,将显示屏上显示的数字增加1,按下蓝色按钮则减少1。
当显示屏上的显示为9时,按红色按钮会变为0;当显示为0时,按蓝色按钮则变为9。
现在,显示屏上显示的数字式是a,当该数字变为b时,锁定打开。那么需要按下按钮至少多少次才能打开锁?
输入格式
第一行,一个整数a,表示当前显示器上的数字。
第二行,一个整数b,表示目标数字。
输出格式
输出最少需要多少步,末尾有换行。
4
6
2
8
1
3
5.11模拟测试
- Status
- Done
- Rule
- Ledo
- Problem
- 6
- Start at
- 2025-5-11 19:15
- End at
- 2025-5-11 20:15
- Duration
- 1 hour(s)
- Host
- Partic.
- 8