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

相关文章

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

leetcode Valid Perfect Square

leetcode Valid Perfect Square  题目:https://leetcode.com/problems/valid-perfect-square/ 解题思路:利用Math.sqrt 获得值是否等于强制Math.sqrt public static void main(String[] args) {int num=16;boolean perfectSquare = i

[LeetCode] 221. Maximal Square

题目内容 https://leetcode-cn.com/problems/maximal-square/ 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: 1 0 1 0 01 0

【科研】常用的实验结果评价指标(1) —— R2(R-square)是什么?

常用的实验结果评价指标(1) —— R2(R-square),可能为负数吗?! 提示:先说概念,后续再陆续上代码 文章目录 常用的实验结果评价指标(1) —— R2(R-square),可能为负数吗?!前言一、R2 基本概念1. R2 是什么?2. R2 的起源3. R2 的计算公式4. R2 是为了衡量或评价什么? 二、R2的适用场景是什么?三、R2是否适用于强非线性数据?如果不

LeetCode: Valid Word Square

这是 LeetCode 上的一题目:Valid Word Square,具体的题目描述如下: Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a valid word square if the kth k^{th} row and column

hdu1398 Square Coins(生成函数)

/......................................................................................................................................................................................................

1052. 【NOIP2016备赛】方阵操作(square)

1052. 【NOIP2016备赛】方阵操作(square)  (Input: square.in, Output: square.out) 时间限制: 1 s 空间限制: 256 MB  题目描述 小 Z 给你一个 n × n 的方阵,要求你完成 Q 次操作: 1. 1 i j k,将 ai,j 修改为 k。 2. 2 i j,交换方阵的第 i 行和第 j 行。 3. 3 i j,交换方