/*
回溯算法加剪枝
在向前走时,判断当前即可剪枝
*/
public class _N_n {
static int min;
static int[] work;
static int[] res;
static int[] task;
static int[][] v;
public static void main(String[] args) {
// TODO Auto-generated method stub
}
static void cal(int cost,int i)
{
if(i==work.length && min>cost)
{
//find
for(int k=0;k<work.length;k++)
{
res[k]=task[k];
}
}
else {
for(int j=0;j<work.length;j++)
{
if(work[j]==0 && cost+v[i][j]<min)
{
work[j]=1;
task[i]=j;
cal(cost+v[i][j], i+1);
work[j]=0;
task[i]=0;
}
}
}
}
}