当前位置:网站首页>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 )
边栏推荐
- Stage experience
- Common features of ES6
- 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)
- Un réveil de l'application B devrait être rapide
- [popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
- Interview related high-frequency algorithm test site 3
- Longyuan war "epidemic" 2021 network security competition web easyjaba
- 【科普】热设计基础知识:5G光器件之散热分析
- 包 类 包的作用域
- [untitled]
猜你喜欢

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

网络安全-记录web漏洞修复

MacBook安装postgreSQL+postgis

WeNet:面向工业落地的E2E语音识别工具

【虚幻引擎UE】实现测绘三脚架展开动画制作

【FineBI】使用FineBI制作自定义地图过程

SPI read / write flash principle + complete code

TPG x AIDU|AI领军人才招募计划进行中!

Mxnet imports various libcudarts * so、 libcuda*. So not found

Kwai, Tiktok, video number, battle content payment
随机推荐
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
What are the building energy-saving software
2022-2028 global and Chinese FPGA prototype system Market Research Report
【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
函数(基本:参数,返回值)
Neural networks and deep learning Chapter 2: machine learning overview reading questions
User behavior collection platform
学习MVVM笔记(一)
After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
Official announcement! The third cloud native programming challenge is officially launched!
OWASP top 10 vulnerability Guide (2021)
Threejs Internet of things, 3D visualization of farm (III) model display, track controller setting, model moving along the route, model adding frame, custom style display label, click the model to obt
The development of mobile IM based on TCP still needs to keep the heartbeat alive
可观测|时序数据降采样在Prometheus实践复盘
Ctfshow 2022 Spring Festival welcome (detailed commentary)
2022-2028 global and Chinese video coding and transcoding Market Research Report
机器学习 --- 神经网络
A real day for Beijing programmers!!!!!
Sword finger offer 04 Search in two-dimensional array
windows下Redis-cluster集群搭建