top of page

소스 코드 제출

공개·회원 50명

a


a = int(input())
k = list(map(int,input().split()))
t = list(map(int,input().split()))
z = [[2,1],[2,-1],[-2,1],[-2,-1],[1,2],[-1,2],[1,-2],[-1,-2]]
x = []
past = []
k.append(0)
x.append(k)
while 1:
    x0 = x[0][0]
    x1 = x[0][1]
    x2 = x[0][2]
    if x0==past[0] and x1 == past[1] and len(past)!= 0:
        x.pop(0)
        continue
    #print(x0,x1,x2,t)
    if x[0][0] == t[0] and x[0][1] == t[1]:
        print(x[0][2])
        break
    for i in range(8):
        if (x0+z[i][0] <= a and x0+z[i][0] > 0) and (x1+z[i][1] <= a and x1+z[i][1] > 0):
            x.append([x0+z[i][0],x1+z[i][1],x2+1])
    past = [x0,x1]
    x.pop(0)


1회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page