Codeforces Beta Round #1

来源:互联网 发布:风电中国 知乎 编辑:程序博客网 时间:2024/06/05 16:15
http://codeforces.com/contest/1/problem/A
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

题目大意:用最少的正方形砖,填矩形,输出最小数量
/* ***********************************************
Author :
Created Time :2015/5/30 21:31:27
File Name :3.cpp
************************************************ */

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;

bool cmp(int a,int b){
return a>b;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
ll n
,m,a;
while(cin>>n>>m>>a){
ll b
=m/a+(m%a==0?0:1);

ll c
=n/a+(n%a==0?0:1);
cout
<<b*c<<endl;

}
return 0;
}


0 0
原创粉丝点击