[蓝桥杯] 移动距离 (Python 实现)

题目:
[蓝桥杯] 移动距离 (Python 实现)

代码:

w, m, n = map(int,input().split())
y = max(m,n)//w + 1
matrix = []
res = []
for i in range(y):
    temp = [j for j in range(w*i+1, w*(i+1)+1)]
    if i%2 == 0:
        matrix.append(temp)
    else:
        temp = temp[::-1]
        matrix.append(temp)
    if m in temp:
        res.append([temp.index(m),i])
    if n in temp:
        res.append([temp.index(n),i]) 
print(abs(res[0][1]-res[1][1]) + abs(res[0][0]-res[1][0]))
上一篇:Ant Design Vue 单文件上传Upload


下一篇:Java学习day12-面向对象特征之二:继承