Skip to content

Baekjoon 1699

1. Problem

문제 확인하기

2. Solution

n = int(input())
dp = [i for i in range (n + 1)]

for i in range(1, n + 1):
    for j in range(1, i):
        if (j * j) > i:
            break
        if dp[i] > dp[i - j * j] + 1:
            dp[i] = dp[i - j * j] + 1

print(dp[n])