[자바] 백준 25757번:임스와

https://www.acmicpc.net/problem/25757

각 플레이어는 게임을 한 번만 플레이하기 때문입니다.

집합으로 저장하면 중복된 사람을 제외할 수 있습니다.

중복 없이 인원수를 세신 후 게임에 필요한 인원수로 나눈 값 – 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);
	}

}