**
最佳加法表达式(求最小值)**
package planning;
import java.util.Scanner;
import java.math.*;
public class Perfectadd {
static String exp;//使用string方便后续使用substring()
static BigInteger num[][]=new BigInteger[10][10];
public static final BigInteger INF=new BigInteger("999999999999999999999");//定义无穷大
static BigInteger sum(int m,int n)
{
if(m==0) return num[1][n];//直接返回
else if(m+1>n) return INF;
else
{
BigInteger t=INF;
for(int i=m;i<=n-1;i++)
t=t.min(num[i+1][n].add(sum(m-1,i)));//所谓实例化
return t;
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();//m个加号
exp=sc.next();
int n=exp.length();
for(int i=1;i<=n;i++)
{
num[i][i]=new BigInteger(exp.substring(i-1, i));
for(int j=i+1;j<=n;j++)
{
num[i][j]=new BigInteger(exp.substring(i-1, j));
}
}
System.out.println(sum(m,n));
}
}