当前位置:网站首页>English topic assignment (27)
English topic assignment (27)
2022-07-05 04:31:00 【m0_ sixty-five million seven hundred and eighty-eight thousand 】
The original title is :
Open the Lock
1000ms 32768K
describe :
Now an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is numbered from 1 to 9.
Each time, you can add or minus 1 to any digit. When add 1 to '9', the digit will change to be '1' and when minus 1 to '1', the digit will change to be '9'. You can also exchange the digit with its neighbor. Each action will take one step.
Now your task is to use minimal steps to open the lock.
Note: The leftmost digit is not the neighbor of the rightmost digit.
Input :
The input file begins with an integer T, indicating the number of test cases.
Each test case begins with a four digit N, indicating the initial state of the password lock. Then followed a line with anotther four dight M, indicating the password which can open the lock. There is one blank line after each test case.
Output :
For each test case, print the minimal steps in one line.
The sample input :
2 1234 2144 1111 9999
Sample output :
2 4
( link :Open the Lock | JXNUOJ)
translate :
The lock
Now I have an urgent task for you —— Unlock the code lock . The code is from 4 It's made up of digits . Every number belongs to 1~9 in .
Each time you can add or subtract 1. When the 9 add 1 when , Change to numbers 1, When the 1 subtract 1 when , Change to numbers 9. You can also exchange two adjacent numbers . Each action counts as a step .
Your task is to unlock with the least number of steps .
Be careful : The leftmost number is not adjacent to the rightmost number .
Input :
Enter an integer first T, Represents the number of test groups . Each test group first enters 4 digit N, Represents the password originally displayed by the password lock . Next line input 4 digit M, Represents the password that can unlock . And there is a space line between each two groups of test arrays .
Output :
For each set of test arrays , Output minimum operand ( Each takes up a line )
边栏推荐
猜你喜欢
[phantom engine UE] the difference between running and starting, and the analysis of common problems
Sequence diagram of single sign on Certification Center
How to get the first few pieces of data of each group gracefully
【虚幻引擎UE】运行和启动的区别,常见问题分析
Common features of ES6
【UNIAPP】系统热更新实现思路
Label exchange experiment
【虚幻引擎UE】实现UE5像素流部署仅需六步操作少走弯路!(4.26和4.27原理类似)
美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
[phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
随机推荐
web资源部署后navigator获取不到mediaDevices实例的解决方案(navigator.mediaDevices为undefined)
Qt蓝牙:搜索蓝牙设备的类——QBluetoothDeviceDiscoveryAgent
Is "golden nine and silver ten" the best time to find a job? Not necessarily
程序员应该怎么学数学
取余操作是一个哈希函数
指针函数(基础)
How should programmers learn mathematics
包 类 包的作用域
【虛幻引擎UE】實現UE5像素流部署僅需六步操作少走彎路!(4.26和4.27原理類似)
Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
mysql的七种join连接查询
Convert Boolean to integer value PHP - Convert Boolean to integer value PHP
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)
Stage experience
Setting up redis cluster cluster under Windows
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
Decimal to hexadecimal
2022-2028 global and Chinese FPGA prototype system Market Research Report
Neural network and deep learning Chapter 1: introduction reading questions
Machine learning -- neural network