자바/백준

[백준 5597] 과제 안 내신 분..?

슈슈버거 2022. 8. 16. 01:09

문제

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

 

5597번: 과제 안 내신 분..?

X대학 M교수님은 프로그래밍 수업을 맡고 있다. 교실엔 학생이 30명이 있는데, 학생 명부엔 각 학생별로 1번부터 30번까지 출석번호가 붙어 있다. 교수님이 내준 특별과제를 28명이 제출했는데,

www.acmicpc.net


내가 작성한 코드

import java.io.*;
import java.util.*;

public class 백준5597 {
    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<Integer> student = new HashSet<>();
        for(int i = 1; i<=30; i++){
            student.add(i);
        }

        for(int i = 0; i<28; i++){
            student.remove(Integer.parseInt(br.readLine()));
        }

        Iterator<Integer> result = student.iterator();

        for(int i = 0; i<2; i++){
            bw.write(Integer.toString(result.next()));
            bw.newLine();
        }

        bw.close();
    }
}

'자바 > 백준' 카테고리의 다른 글

[백준 8370] Plane  (0) 2022.08.16
[백준 7287] 등록  (0) 2022.08.16
[백준 5522] 카드 게임  (0) 2022.08.09
[백준 5339] 콜센터  (0) 2022.08.09
[백준5338] 마이크로소프트 로고  (0) 2022.08.09