알고리즘 풀이/CodeForces

[CodeForces][JAVA] 1A - Theatre Square

배게 2021. 6. 8. 01:07
728x90

10^9 큰 숫자 대비용 long으로 선언

가로m과 세로n을 각각 a로 나눈 값 x,y를 곱해준다

나눴을 때 나머지가 0이 아닌 경우에는 +1을 해준다

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
 
public class HelloWorld {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long m = sc.nextInt();
        long n = sc.nextInt();
        long a = sc.nextInt();
        
        long x = m/a;
        long y = n/a;
        if(m%a!=0) x++;
        if(n%a!=0) y++;
        
        System.out.println(x*y);
            
    }
}
 
 
 
cs