"codeforces--NEFU要崛起——第1场 " A - Theatre Square

来源:互联网 发布:bbi买卖指标源码 编辑:程序博客网 时间:2024/05/17 05:16
                                                                              A -Theatre Square
                             Limit:2000MSMemory Limit:65536KB 64bit IO Format:%I64d & %I64u
 

Description

Theatre Square in the capital city of Berland has a rectangular shape with the sizen × 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 sizea × 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 Input

Input
6 6 4
Output
4

 

 

 

 

 

题意:告诉长和宽 然后一个变长为a的正方形 问需要多少块儿才能全部覆盖前面长宽相乘所得出的面积(必须完全覆盖)

题解:我勒个去 我捣鼓了快一个小时才知道_int64很神奇

代码:

#include<iostream>#include<cstring>#include<cstdio>using namespace std;__int64 num(__int64 x,__int64 y){__int64 num1=x/y;if(x%y!=0) num1=num1+1; return num1;}int main(){__int64 m,n,a;while(cin>>m>>n>>a){ __int64 q=num(m,a); __int64 w=num(n,a); cout<<q*w<<endl; }return 0;}


还有一个一直超时的代码 不知道为什么改了成_int64也没用~

开始的时候错误代码:

#include<iostream>#include<cstring>#include<cstdio>using namespace std;int num(int length,int sl){    __int64 k=0;for(int i=1;i<=length;i++){if(length>sl*i){k=i;}if(length<=sl*i){      break;} }return k+1;}int main(){__int64 l;__int64 w;__int64 sl;__int64 mainji;__int64 a,b;__int64 tatol;while(scanf( "%d%d%d", &l, &w, &sl )!=EOF){a=num(l,sl);b=num(w,sl);tatol=a*b;printf("%d%\n", tatol);//cout<<tatol<<endl;}return 0;}


 

 

 

 

 

 

 

 

 

原创粉丝点击