We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 0d85ab2 + ee6c3e5 commit 71aaf73Copy full SHA for 71aaf73
1 file changed
ksinji/202512/09 BOJ 암호코드.md
@@ -0,0 +1,41 @@
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
34
35
36
37
+ System.out.println(dp[n] % MOD);
38
39
+}
40
41
+```
0 commit comments