Happy New Year! 2024 第一題

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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章