蓝桥杯排队问
public class lanqiao {
public static void main(String[] args) {
int count=0;int max=0;
int[][] ints={{97,90,0 ,0 ,0},
{92,85,96,0 ,0},
{0 ,0 ,0 ,0 ,93},
{0 ,0 ,0 ,80,86},
{89,83,97,0 ,0},
{82,86,0 ,0 ,0},
{0 , 0,0 ,87,90},
{0 ,97,96, 0,0},
{0 ,0 ,89, 0,0},
{95,99,0 ,0 ,0},
{0 ,0 ,96,97,0},
{0 ,0 ,0 ,93,98},
{94,91,0 ,0 ,0},
{0 ,83,87,0 ,0},
{0 ,0 ,98,97,98},
{0 ,0 ,0 ,93,86},
{98,83,99,98,81},
{93,87,92,96,98},
{0 ,0 ,0 ,89,92},
{0 ,99,96,95,81}};
for (int i=0;i<20;i++){
for (int j=0;j<20;j++){
if (j==i){
continue;
}
for (int q=0;q<20;q++){
if (q==j||q==i){
continue;
}
for (int w=0;w<20;w++){
if (w==q||w==i||w==j){
continue;
}
for (int e=0;e<20;e++){
if (e==w||e==i||e==q||e==j){
continue;
}
count=ints[i][0]+ints[j][1]+ints[q][2]+ints[w][3]+ints[e][4];
max=Math.max(count,max);
}
}
}
}
}
System.out.println(max);
}
}
这里我直接使用了蛮搜,因为大概一个人打了一个位置,他就不可能再打其他位置,刚好可以利用coutinue来消除重复。
答案是:480