publicstaticvoidmain(String[] args)throws Exception { BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); out.write("" + easyStair(n)); out.write("\n"); out.flush(); out.close(); in.close(); }
publicstaticlongeasyStair(int n){ long mod = 1000000000L; long[][] dp = newlong[n + 1][10]; for (int i = 1; i <= 9; i++) { dp[1][i] = 1; } for (int i = 2; i <= n; i++) { for (int j = 0; j <= 9; j++) { dp[i][j] = 0; if (j - 1 >= 0) { dp[i][j] += dp[i - 1][j - 1]; } if (j + 1 <= 9) { dp[i][j] += dp[i - 1][j + 1]; } dp[i][j] %= mod; } } long solv = 0; for (int i = 0; i <=9; i++) { solv += dp[n][i]; } return solv %= mod; } }