File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ package etc ;
3+
4+ import java.io.BufferedReader ;
5+ import java.io.BufferedWriter ;
6+ import java.io.IOException ;
7+ import java.io.InputStreamReader ;
8+ import java.io.OutputStreamWriter ;
9+
10+ public class BJ_2591_ 숫자카드 {
11+
12+ private static final BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
13+ private static final BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
14+
15+ private static int len;
16+ private static String input;
17+ private static int [] nums;
18+ private static int [] dp;
19+
20+ public static void main (String [] args ) throws IOException {
21+ init();
22+ sol();
23+ }
24+
25+ private static void init () throws IOException {
26+ input = br. readLine();
27+ len = input. length();
28+
29+ nums = new int [len + 1 ];
30+ dp = new int [len + 1 ];
31+ for (int i = 1 ; i <= len; i++ ) {
32+ nums[i] = input. charAt(i - 1 ) - ' 0' ;
33+ }
34+ dp[0 ] = 1 ;
35+ }
36+
37+ private static void sol () throws IOException {
38+ for (int i = 1 ; i <= len; i++ ) {
39+ if (nums[i] > 0 ) {
40+ dp[i] = dp[i - 1 ];
41+ }
42+
43+ if (i >= 2 && nums[i - 1 ] != 0 && nums[i - 1 ] * 10 + nums[i] <= 34 ) {
44+ dp[i] += dp[i - 2 ];
45+ }
46+ }
47+ bw. write(dp[len] + " " );
48+ bw. flush();
49+ bw. close();
50+ br. close();
51+ }
52+
53+ }
54+ ```
You can’t perform that action at this time.
0 commit comments