• 문제 링크
16524번: Database of Clients
The first line contains an integer N (1 ≤ N ≤ 1000) representing the number of email addresses in the database. Each of the next N lines contains a string of at most 100 characters representing an email address in the database. Each email address has t
www.acmicpc.net
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Set<String> set = new HashSet<>();
int n = Integer.parseInt(br.readLine());
while (n-- > 0) {
String s = br.readLine();
int p = s.indexOf('@'), i = s.indexOf('+');
set.add(s.substring(0, i == -1 ? p : i).replace(".", "") + s.substring(p));
}
bw.write(String.valueOf(set.size()));
bw.flush();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 6798 Knight Hop - Graph Theory / Java (0) | 2023.11.12 |
---|---|
[백준] 4575 Refrigerator Magnets - Data Structure / Java (0) | 2023.11.11 |
[백준] 25329 학생별 통화 요금 계산 - Data Structure / Java (0) | 2023.11.09 |
[백준] 6165 Game of Lines - Data Structure / Java (0) | 2023.11.08 |
[백준] 26043 식당 메뉴 - Data Structure / Java (0) | 2023.11.07 |
댓글