File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-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 Exception {
8+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
9+ String s = br. readLine();
10+
11+ int n = s. length();
12+ if (n == 0 || 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+ dp[1 ] = 1 ;
20+
21+ for (int i = 2 ; i <= n; i++ ) {
22+ char c1 = s. charAt(i - 1 );
23+ char c0 = s. charAt(i - 2 );
24+
25+ if (c1 != ' 0' ) {
26+ dp[i] += dp[i - 1 ];
27+ dp[i] %= MOD ;
28+ }
29+
30+ int two = (c0 - ' 0' ) * 10 + (c1 - ' 0' );
31+ if (two >= 10 && two <= 26 ) {
32+ dp[i] += dp[i - 2 ];
33+ dp[i] %= MOD ;
34+ }
35+ }
36+
37+ System . out. println(dp[n] % MOD );
38+ }
39+ }
40+
41+ ```
You can’t perform that action at this time.
0 commit comments