dp[i]表示第i点到1点的距离
import math
dp =[ 0 for i in range(2022)]
for i in range(2,23):
dp[i] = i
def lcd(a,b):
gcd = math.gcd(a,b)
return (a*b)//gcd
for i in range(23,2022):
min=math.inf
for j in range(1,22):
if (dp[i-j]+lcd(i-j,i))<min:
min=dp[i-j]+lcd(i-j,i)
dp[i] = min
print(dp[-1])