Codeforces Beta Round #1

来源:互联网 发布:如何找出excel重复数据 编辑:程序博客网 时间:2024/05/22 00:54

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.

<p< p=""><p< p="">
Input
<p< p="">

The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

<p< p=""><p< p="">
Output
<p< p="">

Write the needed number of flagstones.

<p< p=""><p< p="">
Sample test(s)
<p< p=""><p< p="">
input
6 6 4
output
4


一题用数学知识来解答的水题······计算广场的长和宽各需要多少砖····简单的数学问题····还要注意铺完的地方要与边平行!!

#include<iostream>#include<iomanip>#include<string>#include<stdio.h>using namespace std;int main( ){    long long n,m,a,s1,s2,sum;    while(cin>>n>>m>>a)    {       if(a>=n&&a>=m)       sum=1;       else       {           s1=n/a;           if(n%a!=0)           s1=s1+1;           s2=m/a;           if(m%a!=0)           s2=s2+1;           sum=s1*s2;       }       cout<<sum<<endl;    }    return 0;}







原创粉丝点击