Skip to content

Commit 8bf2516

Browse files
authored
[20250920] BOJ / G4 / 로또 / 이종환
1 parent cddd2af commit 8bf2516

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

0224LJH/202509/20 BOJ 로또.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
```java
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.util.*;
6+
7+
public class Main {
8+
9+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
11+
static int[] arr;
12+
static long[][] dp;
13+
static int numCnt, max;
14+
static long ans;
15+
16+
public static void main(String[] args) throws NumberFormatException, IOException {
17+
int TC = Integer.parseInt(br.readLine());
18+
for (int tc =1; tc <= TC; tc++) {
19+
init();
20+
process();
21+
print();
22+
}
23+
24+
}
25+
26+
public static void init() throws NumberFormatException, IOException {
27+
StringTokenizer st = new StringTokenizer(br.readLine());
28+
numCnt = Integer.parseInt(st.nextToken());
29+
max = Integer.parseInt(st.nextToken());
30+
arr = new int[numCnt];
31+
dp = new long[numCnt][max+1];
32+
ans = 0;
33+
}
34+
35+
public static void process() {
36+
Arrays.fill(dp[numCnt-1], 1);
37+
for (int i = numCnt-1; i > 0; i--) {
38+
for (int j = max; j >=0; j--) {
39+
dp[i-1][j/2] += dp[i][j];
40+
}
41+
for (int j = max; j > 0; j--) {
42+
dp[i-1][j-1] += dp[i-1][j];
43+
}
44+
}
45+
46+
for (int i = 0; i < numCnt; i++) {
47+
for (int j = 0; j <= max; j++) {
48+
System.out.print (dp[i][j]+ " ");
49+
}
50+
System.out.println();
51+
}
52+
for (int i = 1; i <= max; i++) {
53+
54+
ans += dp[0][i];
55+
}
56+
57+
}
58+
59+
60+
61+
public static void print() {
62+
System.out.println(ans);
63+
}
64+
}
65+
```

0 commit comments

Comments
 (0)