Problem Description
My Problem Report
非常简单的dp==似乎没有什么可写的
P.S. 这道题我代码写得略丑,感觉刘汝佳那种写法更好些
My Source Code
// Created by Chlerry in 2015.
// Copyright (c) 2015 Chlerry. All rights reserved.
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define Size 100000
#define ll long long
#define mk make_pair
#define pb push_back
#define mem(array, x) memset(array,x,sizeof(array))
typedef pair<int,int> P;
int len,n,f[60][60],a[60];
int main()
{
freopen("in.txt","r",stdin);
while(cin>>len && len)
{
cin>>n;a[++n]=len;
for(int i=1;i<n;i++)
cin>>a[i];
for(int i=1;i<n;i++)
for(int j=1;j+i<=n;j++)
{
f[j][j+i]=INT_MAX;
for(int k=j;k<j+i;k++)
f[j][j+i]=min(f[j][j+i],f[j][k]+f[k+1][j+i]+a[j+i]-a[j-1]);
}
cout<<"The minimum cutting is "<<f[1][n]<<".\n";
}
return 0;
}