我是靠谱客的博主 悦耳鸡,这篇文章主要介绍1A. Theatre Square,现在分享给大家,希望可以做个参考。

一、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.内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部