문제/백준_자바
173. 3003(킹, 퀸, 룩, 비숍, 나이트, 폰) - 자바
sm_hope
2022. 8. 13. 12:38
import java.util.*;
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] chessPiece = { 1, 1, 2, 2, 2, 8 };
String[] tmp = br.readLine().split(" ");
List<String> result = new ArrayList<>();
for (int i = 0; i < chessPiece.length; i++) {
result.add(String.valueOf(chessPiece[i] - Integer.parseInt(tmp[i])));
}
System.out.println(String.join(" ", result));
}
}
문제요약
킹 1 퀸 1 룩 2 비숍 2 나이트 2 폰 8이 되도록 만들어라
설명
체스판에 필요한 말들의 각각의 개수를 리스트로 저장하였다.
int[] chessPiece = { 1, 1, 2, 2, 2, 8 };
말들의 값에서 입력된 값을 빼준다면 필요한 말의 개수를 알 수 있다.
for (int i = 0; i < chessPiece.length; i++) {
result.add(String.valueOf(chessPiece[i] - Integer.parseInt(tmp[i])));
}