CF #1 A. Theatre Square

Source: Internet
Author: User
Tags integer numbers time limit

Http://codeforces.com/contest/1/problem/A

A. Theatre Square time limit per test 2 seconds memory limit per test megabytes input standard input Output standard OU Tput

Theatre Square in the Berland have a rectangular shape with the size nxm meters. On the occasion of the city ' s anniversary, a decision is taken to pave the square with square granite flagstones. Each flagstone is of the size AXA.

What's 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 have to be covered. It's not a allowed to break the flagstones. The sides of flagstones should is 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. Sample Test (s) input

6 6 4
Output
4
The main topic:: To a n*m square paving tiles, floor tiles for a square, side long for a, can not destroy the floor tiles, ask the minimum number of blocks required

#include <iostream>

using namespace std;

int main ()
{
    long long  n,m,a;
    while (Cin>>n>>m>>a)
    {
        if (n%a==0)
            n=n/a;
        else
            n=n/a+1;
        if (m%a==0)
            m=m/a;
        else
            m=m/a+1;
        cout<<n*m<<endl;
    }
    return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.