Bakejoon - 1373

Tadap·2023년 11월 16일
0

Baekjoon

목록 보기
84/94

문제

오늘은 쉬어가는 문제

1차시도

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		sb.append(" ");
		String[] split = br.readLine().split("");

		for (int i = 0; i < split.length; i += 3) {
			int visit = split.length - i - 1;
			int value = 0;

			if (visit - 2 > -1) {
				value += Integer.parseInt(split[visit - 2]) * 4;
			}
			if (visit - 1 > -1) {
				value += Integer.parseInt(split[visit - 1]) * 2;
			}
			value += Integer.parseInt(split[visit]);

			sb.insert(0, value);
		}
		System.out.println(sb);
	}
}

성공

0개의 댓글