Happy New Year! 2024 第一题

发布时间 2024-01-11 20:28:58作者: Shendu.CC

A. Theatre Square
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.

Examples
inputCopy
6 6 4
outputCopy
4

太久太久没有刷题了,已经忘记c++怎么写了,打开文件,不知道第一行该写什么?上班的时候一直用c#,用到已经忘记别的语言了。
选了一道非常简单的题目,甚至提交的时候还编译错误了。

CodeForces的提交,成功会显示Happy New Year!

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>


using namespace std;

long long n, m, a;

int main()
{
    scanf("%d%d%d", &n, &m, &a);

    long long x = n / a;
    if(n % a != 0)
    {
        x++;
    }

    long long y = m / a;
    if(m % a != 0)
    {
        y++;
    }

    printf("%lld\n", x * y);
    return 0;
}