File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ ```java
2+ import java.io.*;
3+
4+ public class Main {
5+ static final int MOD = 1000000;
6+
7+ public static void main(String[] args) throws IOException {
8+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+ String s = br.readLine();
10+ int n = s.length();
11+
12+ if (s.charAt(0) == '0') {
13+ System.out.println(0);
14+ return;
15+ }
16+
17+ int[] dp = new int[n + 1];
18+ dp[0] = 1;
19+
20+ for (int i = 1; i <= n; i++) {
21+ int one = s.charAt(i - 1) - '0';
22+ if (one >= 1 && one <= 9) {
23+ dp[i] = (dp[i] + dp[i - 1]) % MOD;
24+ }
25+
26+ if (i >= 2) {
27+ int two = (s.charAt(i - 2) - '0') * 10 + one;
28+ if (two >= 10 && two <= 26) {
29+ dp[i] = (dp[i] + dp[i - 2]) % MOD;
30+ }
31+ }
32+ }
33+
34+ System.out.println(dp[n]);
35+ }
36+ }
37+
38+ ```
You can’t perform that action at this time.
0 commit comments