• 문제 링크
2563번: 색종이
가로, 세로의 크기가 각각 100인 정사각형 모양의 흰색 도화지가 있다. 이 도화지 위에 가로, 세로의 크기가 각각 10인 정사각형 모양의 검은색 색종이를 색종이의 변과 도화지의 변이 평행하도록
www.acmicpc.net
• 풀이 과정
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st;
int n = Integer.parseInt(br.readLine());
int[][] arr = new int[100][100];
int cnt = 0;
for (int t = 0; t < n; t++) {
st = new StringTokenizer(br.readLine());
int y = Integer.parseInt(st.nextToken());
int x = Integer.parseInt(st.nextToken());
for (int i = y; i < y + 10; i++) {
for (int j = x; j < x + 10; j++) {
if (arr[i][j] == 1)
continue;
arr[i][j] = 1;
cnt++;
}
}
}
bw.write(cnt + "\n");
bw.flush();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 2980 도로와 신호등 - Implementation / Java (0) | 2022.06.06 |
---|---|
[백준] 8979 올림픽 - Implementation / Java (0) | 2022.06.05 |
[백준] 3048 개미 - Implementation / Java (0) | 2022.06.02 |
[백준] 10798 세로읽기 - Implementation / Java (0) | 2022.06.01 |
[백준] 8911 거북이 - Implementation / Java (0) | 2022.05.31 |
댓글