본문 바로가기
Problem Solving/Baekjoon

[백준] 11104 Fridge of Your Dreams - Implementation / Java

by graycode 2025. 5. 25.

 문제 링크

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

 

 풀이 코드

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class Main {

    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args) throws IOException {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder sb = new StringBuilder();

        int n = Integer.parseInt(read());
        while (n-- > 0) sb.append(Integer.parseInt(read(), 2)).append('\n');

        bw.write(sb.toString());
        bw.flush();
    }

    private static String read() throws IOException {
        sb.setLength(0);
        int c;
        while ((c = System.in.read()) > 47) sb.append((char) c);

        return sb.toString();
    }

}

댓글