摘要:
#include #include int a[2001];int dp[2001][1001]={0};using namespace std;int main(){ int n,k,i=1,j=1;while(scanf("%d %d",&n,&k)==2){for(i=1;i2*j) dp[i][j]=min(dp[i-1][j],dp[i-2][j-1]+(a[i]-a[i-1])*(a[i]-a[i-1]));}printf("%d\n",dp[n][k]);} return 0;} 阅读全文