-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1972(String).java
More file actions
51 lines (46 loc) ยท 1.91 KB
/
Copy path1972(String).java
File metadata and controls
51 lines (46 loc) ยท 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
public class Main {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder answer = new StringBuilder();
String s = "";
int count = 0;
while(!s.equals("*") && count < 101){
s = br.readLine();
count++;
int check = 0;
int num = s.length();
for(int i = 1; i < num; i++){ // 1, 2, 3
int leng = num-i;
String arr[] = new String[leng]; //๋ฐฐ์ด๊ธธ์ด 3 -> 2 -> 1
HashSet<String> set = new HashSet<>();
for(int j = 0; j < leng; j++){
//์ค๋ณตํ์ธ ํด์๋งต์ ๋ฃ์ด๋ฒ๋ฆฌ๊ณ ๊ฐ์๋ฅผ ๋ฐฐ์ด์ ์ฒด์์๊ฐ์๋ ๋น๊ตํด์ ์ฐจ์ด๋๋ฉด false?
StringBuilder sb = new StringBuilder();
sb.append(s.charAt(j)).append(s.charAt(j+i));
set.add(sb.toString());
}
if(leng != set.size()){
check = 1;
break;
}
}
if(!s.equals("*")){
if(check == 1){
answer.append(s).append(" is NOT surprising.").append('\n');
}else{
answer.append(s).append(" is surprising.").append('\n');
}
}
}
System.out.println(answer);
}
}
//1. ๋ฌธ์์ด ๊ธธ์ด ํ์ธ
//2. ๊ฒฝ์ฐ์ ์ ํ์ธ ( ex, 4์ ๊ธธ์ด๋ฅผ ๊ฐ์ง ๋ฌธ์์ด์ 1์์ฐจ์ด, 2์์ฐจ์ด 3์์ฐจ์ด ๊ฒฝ์ฐ ํฌ๊ฒ 3๊ฐ
//2-1 1์์ฐจ์ด์์๋ 0,1 1,2 2,3 ๊ฐ๋ฅ (3๊ฐ)
//์ ์ฒด๊ฒฝ์ฐ๋ ์ ์ฒด๊ธธ์ด -1.
//ZGBG ๋ค์์ ์นด์ดํ
ํด๋ ๋ฌธ์ x 3,2 2,1 1,0 (i์์์ leng-1)