ZOAC 4
in Algorithm on SW Expert Academy
백준 [23971] ZOAC 4
풀이
한줄에서 세로에서 가능한 배치 갯수와 가로에서 가능한 배치 갯수를 각각 구해 곱한다
소스코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int H = sc.nextInt(); // 행
int W = sc.nextInt(); // 열
int N = sc.nextInt(); // 세로 거리
int M = sc.nextInt(); // 가로 거리
int vertical = countNum(N, H);
int horizontal = countNum(M, W);
System.out.println(vertical * horizontal);
}
private static int countNum(int distance, int length) {
int count = 1;
int start = 1;
while (start < length) {
start += distance + 1;
if (start <= length) {
count++;
}
}
return count;
}
}