概述
一、Problem
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city’s anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.
What is the least number of flagstones needed to pave the Square? It’s allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It’s not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.
Input
The input contains three positive integer numbers in the first line: n, m and a (1 ≤ n, m, a ≤ 109).
Output
Write the needed number of flagstones.
二、Code
input
6 6 4
output
4
三、代码
package com.codeforces.problemset;
import java.util.Scanner;
public class TheatreSquare {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long m = sc.nextLong();
long a = sc.nextLong();
System.out.println(theatreSquare(n, m, a));
}
private static long theatreSquare(long n, long m, long a) {
long length = n % a == 0 ? n / a : n / a + 1;
long width = m % a == 0 ? m / a : m / a + 1;
long count = length * width;
return count;
}
}
最后
以上就是悦耳鸡为你收集整理的1A. Theatre Square的全部内容,希望文章能够帮你解决1A. Theatre Square所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复