File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments