当前位置:网站首页>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 )
边栏推荐
- 蛇形矩阵
- Sword finger offer 07 Rebuild binary tree
- Common features of ES6
- Sword finger offer 04 Search in two-dimensional array
- You Li takes you to talk about C language 7 (define constants and macros)
- Network security - record web vulnerability fixes
- C26451: arithmetic overflow: use the operator * on a 4-byte value, and then convert the result to an 8-byte value. To avoid overflow, cast the value to wide type before calling the operator * (io.2)
- A應用喚醒B應該快速方法
- 程序员应该怎么学数学
- Mxnet imports various libcudarts * so、 libcuda*. So not found
猜你喜欢
![[phantom engine UE] package error appears! Solutions to findpin errors](/img/d5/6747e20da6a8a4ca461094bd27bbf0.png)
[phantom engine UE] package error appears! Solutions to findpin errors

3 minutes learn to create Google account and email detailed tutorial!

如何优雅的获取每个分组的前几条数据

Technical tutorial: how to use easydss to push live streaming to qiniu cloud?

官宣!第三届云原生编程挑战赛正式启动!

Threejs Internet of things, 3D visualization of farms (II)

【虛幻引擎UE】實現UE5像素流部署僅需六步操作少走彎路!(4.26和4.27原理類似)

Is "golden nine and silver ten" the best time to find a job? Not necessarily

Kwai, Tiktok, video number, battle content payment

Learning notes 8
随机推荐
解密函数计算异步任务能力之「任务的状态及生命周期管理」
Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
托管式服务网络:云原生时代的应用体系架构进化
[popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
How should programmers learn mathematics
揭秘技术 Leader 必备的七大清奇脑回路
自动语音识别(ASR)研究综述
Practice | mobile end practice
函数(易错)
TPG x AIDU|AI领军人才招募计划进行中!
About the prompt loading after appscan is opened: guilogic, it keeps loading and gets stuck. My personal solution. (it may be the first solution available in the whole network at present)
[thingsboard] how to replace the homepage logo
SPI read / write flash principle + complete code
3 minutes learn to create Google account and email detailed tutorial!
Introduction to RT thread kernel (5) -- memory management
A application wakes up B should be a fast method
Matplotlib draws three-dimensional scatter and surface graphs
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
Threejs Internet of things, 3D visualization of farms (II)
Sequence diagram of single sign on Certification Center