-
백준 2563 - 색종이(JAVA)Algorithm 2022. 10. 2. 14:19728x90
처음 이 문제를 보면 잘 이해가 안 된다. 하지만 입력 예시를 보면 생각보다 간단하게 이해가 된다. 위에서 설명한 문제 그림 그래도를 입력받고 출력시키기 때문이다.
※ 알고리즘
1. 입력 받는 수(반복 갯수)
2. 도화지를 표현할 이차원 배열 arr
3. StringTokenizer로 한 칸이 띄워진 입력(왼쪽 하단 모서리 좌표값)을 입력 받는다.
4. 입력 받은 모서리 좌표값에서 10씩 더하면 사각형의 넓이이므로 이중 for문을 사용한다.
5. 만약 arr 배열이 false라면 그걸 true로 변화시켜주고 count++ 시켜 count로 넓이를 출력시킨다.
0,1이 아닌 조금 다른 방식의 boolean을 사용해 보았다. 생각보다 편리하게 사용될 수 있어 잘 만 활용하면 강력한 무기가 될 수 있을 것 같다.
728x90'Algorithm' 카테고리의 다른 글
백준 9506 - 약수들의 합(JAVA) (1) 2022.10.03 백준 2609 - 최대공약수와 최소공배수(JAVA) (0) 2022.10.02 백준 2775 - 부녀회장이 될테야(JAVA) (0) 2022.09.28 백준 10769 - 행복한지 슬픈지(JAVA) (0) 2022.09.28 백준 1296 - 팀 이름 정하기(JAVA) (0) 2022.09.27