解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class 超级玛丽 { static int result=0;//方案书数 static int a[]; static int length; public static void main(String[] args) { Scanner in=new Scanner(System.in); length=in.nextInt()+1; a=new int[length]; int num=in.nextInt();//陷阱个数 for(int i=0;i<num;i++){ int temp=in.nextInt(); if(temp<length-1) a[temp]=1; } dfs(1); System.out.println(result); } private static void dfs(int i) {//i表示当前位置 if(i==length-1)result++; if(i>=length)return; if(a[i]==1)return;//当前位置为陷阱 dfs(i+1); dfs(i+2); } }
0.0分
0 人评分
数组输出 (C语言代码)浏览:767 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1146 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:349 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:825 |
Minesweeper (C语言描述,蓝桥杯)浏览:1124 |
演讲大赛评分 (C语言代码)浏览:1629 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:611 |
1073题解浏览:622 |
C语言训练-斐波纳契数列 (C语言代码)浏览:593 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:671 |