Skip to content

Commit 925d4df

Browse files
authored
Merge pull request #982 from AlgorithmWithGod/zinnnn37
[20250926] BOJ / G5 / 문자열 복사 / 김민진
2 parents 350a9a3 + 05a39b7 commit 925d4df

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
```java
2+
import java.io.*;
3+
4+
public class BJ_2195_문자열_복사 {
5+
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
9+
private static String needle, haystack;
10+
11+
public static void main(String[] args) throws IOException {
12+
sol();
13+
}
14+
15+
private static void sol() throws IOException {
16+
needle = br.readLine();
17+
haystack = br.readLine();
18+
19+
int cnt = 0;
20+
int start = 0;
21+
int len = haystack.length();
22+
while (start < len) {
23+
int end = start + 1;
24+
25+
while (end <= len && needle.indexOf(haystack.substring(start, end)) != -1) {
26+
end++;
27+
}
28+
29+
start = end - 1;
30+
cnt++;
31+
}
32+
33+
bw.write(cnt + "\n");
34+
bw.flush();
35+
bw.close();
36+
br.close();
37+
}
38+
39+
}
40+
```

0 commit comments

Comments
 (0)