https://www.acmicpc.net/problem/25757
#25757: 임스와 함께하는 미니 게임
첫 번째 줄은 플레이할 게임 유형을 나타냅니다. B. $N$명의 사람들이 Eames와 플레이하기 위해 등록한 횟수. $(1 \le N \le 100\,000)$ 두 번째 행에서 $N$ 행은 함께 플레이할 사람입니다.
www.acmicpc.net
각 플레이어는 게임을 한 번만 플레이하기 때문입니다.
집합으로 저장하면 중복된 사람을 제외할 수 있습니다.
중복 없이 인원수를 세신 후 게임에 필요한 인원수로 나눈 값 – 1 (1은 Eames이므로 1을 뺍니다).
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
public class P25757 {
public static void main(String() args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
char game = st.nextToken().charAt(0);
HashSet<String> people = new HashSet<>();
for (int i = 0; i < n; i++) {
people.add(br.readLine());
}
int peopleNum = people.size();
int result = 0;
if (game == 'Y') {
result = peopleNum;
} else if (game == 'F') {
result = peopleNum / 2;
} else if (game == 'O') {
result = peopleNum / 3;
}
System.out.println(result);
}
}