We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 49941d9 commit 41daeeeCopy full SHA for 41daeee
1 file changed
JHLEE325/202603/06 BOJ G3 선물 전달.md
@@ -0,0 +1,32 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws Exception {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ int N = Integer.parseInt(br.readLine());
9
10
+ if (N == 1) {
11
+ System.out.println(0);
12
+ return;
13
+ }
14
+ if (N == 2) {
15
+ System.out.println(1);
16
17
18
19
+ long[] dp = new long[N + 1];
20
+ long mod = 1000000000;
21
22
+ dp[1] = 0;
23
+ dp[2] = 1;
24
25
+ for (int i = 3; i <= N; i++) {
26
+ dp[i] = (i - 1) * (dp[i - 1] + dp[i - 2]) % mod;
27
28
29
+ System.out.println(dp[N]);
30
31
+}
32
+```
0 commit comments