梦醒时分2019:public class Main {
private static int sum = 0;
public static int[] scores = {2,2,2,2,2,2,2,2,2,2,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8};
public static void main(String[] args) {
for (int i = 0; i <= 100; i+=2) {
sum = 0;
backTracking(0, 0, 0, i);
System.out.println(i + ": " + sum);
}
}
public static void backTracking(int index, int score, int errNum, int target){
if (errNum >= 3) return;
if (score == target) {
sum++;
return;
}
if (score > target) {
return;
}
for (int i = index; i < 25; i++) {
score += scores[i];
backTracking(i + 1, score,errNum,target);
score -= scores[i];
errNum++;
}
}
}
投递华为等公司10个岗位 >
0 点赞 评论 收藏
分享
关注他的用户也关注了: