1928 Base64 Decoder

Sungmin·2023년 10월 24일
0

SWEA 알고리즘

목록 보기
2/26

Base64 Decoder URL

Solution

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

public class SW1928 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int T = Integer.parseInt(br.readLine());

        for (int i = 1; i <= T; i++) {
            String str = br.readLine();
            String result = new String(Base64.getDecoder().decode(str));
            System.out.println("#" + i + " " + result);
        }
    }
}

배운점

과정이 복잡해서 라이브러리를 사용하지 않고 풀기 쉽지않다.
1. 표를 보고 입력받은 문자를 각각 대응하는 숫자들로 변환
2. 각 숫자들을 6자리 이진수로 표현하고 이진수들을 나열
3. 나열한 이진수들을 8자리씩 끊는다
4. 8자리씩 끊은 수 각각을 십진수로 변환
5. 각 십진수들을 아스키코드로 변환
하는 과정을 모두 거쳐야 되는 복잡한 문제였다.

자바에 인코딩/디코딩 라이브러리가 있는데
java.util.Base64를 사용하면 쉽게 구현할 수 있다.

profile
Let's Coding

0개의 댓글