#include <stdio.h>
int bottom_up(int n){
int dp[100001]={0,};
for(int i=1; i<=n; i++) {
//최악의 경우
dp[i]=i;
for(int j=1; j*j<=i; j++) {
if(dp[i]>dp[i-j*j]+1) dp[i]=dp[i-j*j]+1;
}
}
return dp[n];
}
int main() {
int n;
scanf("%d",&n);
printf("%d",bottom_up(n));
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: