0
public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner = new Scanner(System.in); int n = Integer.parseInt(scanner.nextLine()); int[] t = new int[n]; for (int i = 0; i < n; i++) { t[i] = Integer.parseInt(scanner.nextLine()); } cal(t); //cal_qs();// test } static void cal(int[] t) { int iarr[] = new int[10000]; iarr[0] = 1; int[] b = new int[] { 1, 3, 7, 8 }; for (int i = 1; i < iarr.length; i++) { for (int j = 0; j < 4; j++) { // 使对方一定输,则赢 if (i - b[j] >= 0 && iarr[i - b[j]] == 0) { iarr[i] = 1; } } } for (int i = 0; i < t.length; i++) { System.out.print(iarr[t[i]] + "\n"); } }
蓝桥杯——说好的进阶之取数博弈游戏(动态规划实现),布布扣,bubuko.com
原文地址:http://blog.csdn.net/hymanxq/article/details/25361129