A. Theatre Square

2024-06-19 16:58
文章标签 square theatre

本文主要是介绍A. Theatre Square,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

A. Theatre Square
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard 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.

Sample test(s)
input
6 6 4
output
4


#include<iostream>
using namespace std;int main(){int n, m, a;cin>>n>>m>>a;long long i, j;i = n/a;j = m/a;if(n%a){i++;}if(m%a){j++;}long long sum=i*j;cout<<sum<<endl;return 0;
}


这篇关于A. Theatre Square的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1075606

相关文章

[LeetCode] 221. Maximal Square

题:https://leetcode.com/problems/maximal-square/description/ #题目 Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. Example: Input:

Sum of Square Numbers

Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: 5Output: TrueExplanation: 1 * 1 + 2 * 2 = 5 Example 2: Inpu

python 实现perfect square完全平方数算法

python 实现perfect square完全平方数算法介绍 完全平方数(Perfect Square)是一个整数,它可以表示为某个整数的平方。例如,1,4,9,16,25,… 都是完全平方数,因为 1 = 1 2 , 4 = 2 2 , 9 = 3 2 1=1^2,4=2^2,9=3^2 1=12,4=22,9=32,依此类推。 要判断一个给定的数 n 是否是完全平方数,有几种方法可以

Fill the Square

中文题目解释详见我的博客:http://xiaoshig.sinaapp.com/?p=94   In this problem, you have to draw a square using uppercase English Alphabets. To be more precise, you will be given a square grid with some empty bl

Leetcode176: Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following matrix: 1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0

Ural 1073 Square Country (DP)

题目地址:Ural 1073 DP水题。也可以说是背包。 #include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#in

Codeforces #247 (Div. 2) A. Black Square

水题一道,4分钟AC 代码如下: #include <cstdio>#include <iostream>#include <algorithm>#define MAXN 100010#define ll long longusing namespace std;int a[MAXN];int main(void) {for(int i=1; i<=4; ++i) {cin >>

chi-square, chi-distribute与Guassian distribute近似

chi-distribute is closer to Guassian distribute than chi-square.

LeetCode-367. Valid Perfect Square

问题:https://leetcode.com/problems/valid-perfect-square/?tab=Description Given a positive integer num, write a function which returns True if num is a perfect square else False. 给定一个正数,如果它是某一个数的平方则返回t

[LeetCode] Maximal Square

Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing all 1’s and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0