Etc/알고리즘

[백준] 1076

jjuni_96 2024. 7. 4. 21:58
728x90

문제

 

입력

 

출력

 

문제 분석

입력을 아래와같이 세개를 받음

a, b, c

 

그러면 결과값은 (ab) *c 로 단순 계산하면 될 것 같다.

(여기서 ab는 그냥 문자 그대로 이어 붙임)

 

풀이

import java.util.HashMap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        String[] colorList = {"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"};
        HashMap<String, int[]> colorMap = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            int[] colorValues = new int[2];
            colorValues[0] = i;
            colorValues[1] = (int) Math.pow(10, i);
            colorMap.put(colorList[i], colorValues);
        }
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader bf = new BufferedReader(inputStreamReader);

        int a = colorMap.get(bf.readLine())[0];
        int b = colorMap.get(bf.readLine())[0];
        int c = colorMap.get(bf.readLine())[1];

        Long answer = 0L;
        answer = (long) (10*a+b) *c;

        System.out.println(answer);
    }
}

 

알고리즘 분류

더보기

- 구현

 

 

728x90
반응형
LIST