Skip to content

Commit 5d91d49

Browse files
authored
Merge pull request #54 from AlgorithmWithGod/khj20006
[20250206] BOJ / 골드2 / 집합의 개수 / 권혁준
2 parents 2888b5a + c95be1c commit 5d91d49

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
```java
2+
3+
import java.util.*;
4+
import java.io.*;
5+
6+
class Main {
7+
8+
// IO field
9+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
11+
static StringTokenizer st;
12+
13+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
14+
static int nextInt() {return Integer.parseInt(st.nextToken());}
15+
static long nextLong() {return Long.parseLong(st.nextToken());}
16+
static void bwEnd() throws Exception {bw.flush();bw.close();}
17+
18+
// Additional field
19+
static int[] dp;
20+
static int[] cnt;
21+
static int T, A, S, B;
22+
static int mod = 1000000;
23+
24+
25+
public static void main(String[] args) throws Exception {
26+
27+
ready();
28+
solve();
29+
30+
bwEnd();
31+
}
32+
33+
static void ready() throws Exception{
34+
35+
nextLine();
36+
T = nextInt();
37+
A = nextInt();
38+
S = nextInt();
39+
B = nextInt();
40+
dp = new int[A+1];
41+
cnt = new int[201];
42+
43+
nextLine();
44+
for(int i=0;i<A;i++) cnt[nextInt()]++;
45+
46+
}
47+
48+
static void solve() throws Exception{
49+
50+
dp[0] = 1;
51+
52+
for(int i=1;i<=200;i++) {
53+
int[] ndp = new int[A+1];
54+
ndp[0] = 1;
55+
56+
for(int j=1;j<=A;j++) {
57+
for(int k=0;k<=Math.min(j, cnt[i]);k++) {
58+
ndp[j] += dp[j-k];
59+
ndp[j] %= mod;
60+
}
61+
}
62+
dp = ndp;
63+
}
64+
65+
int ans = 0;
66+
for(int j=S;j<=B;j++) ans = (ans + dp[j]) % mod;
67+
68+
bw.write(ans+"\n");
69+
70+
}
71+
72+
}
73+
74+
```

0 commit comments

Comments
 (0)