public class TestStrangeGame { public static void main(String[] args) { f(0, 10); } static int[] arr = new int[10]; public static void f(int time, int score) { if (time == 10) { if (score == 100) { for (int i = 0; i < arr.length; i++) { System.out.print(arr[i]); } System.out.println(); } } else { arr[time] = 1; f(time + 1, score * 2); arr[time] = 0; f(time + 1, score - time - 1); } } }
原文地址:http://blog.csdn.net/tracysilocean/article/details/26098735