当前位置:网站首页>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 )
边栏推荐
- 指针函数(基础)
- Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
- Raki's notes on reading paper: code and named entity recognition in stackoverflow
- [untitled]
- 取余操作是一个哈希函数
- 假设检验——《概率论与数理统计》第八章学习笔记
- Function (basic: parameter, return value)
- 官宣!第三届云原生编程挑战赛正式启动!
- Fuel consumption calculator
- Invalid bound statement (not found) in idea -- problem solving
猜你喜欢
托管式服务网络:云原生时代的应用体系架构进化
Learning notes 8
Power management bus (pmbus)
快手、抖音、视频号交战内容付费
Setting up redis cluster cluster under Windows
User behavior collection platform
[thingsboard] how to replace the homepage logo
【虚幻引擎UE】实现UE5像素流部署仅需六步操作少走弯路!(4.26和4.27原理类似)
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
防护电路中的元器件
随机推荐
Fuel consumption calculator
2022-2028 global and Chinese equipment as a Service Market Research Report
A real day for Beijing programmers!!!!!
【thingsboard】替换首页logo的方法
Decimal to hexadecimal
Managed service network: application architecture evolution in the cloud native Era
Matplotlib draws three-dimensional scatter and surface graphs
windows下Redis-cluster集群搭建
How to remove installed elpa package
[illusory engine UE] method to realize close-range rotation of operating objects under fuzzy background and pit recording
Fonction (sujette aux erreurs)
A应用唤醒B应该快速方法
Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices
How to carry out "small step reconstruction"?
Machine learning decision tree
2022-2028 global and Chinese virtual data storage Market Research Report
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
The scale of computing power in China ranks second in the world: computing is leaping forward in Intelligent Computing
首席信息官如何利用业务分析构建业务价值?