codeforces的第一场的第一题,原以为自己肯定一次就ac,结果没想到还wa了
题意:一个n*m的广场要铺地板,每块地板的是a*a的矩形。问最少多少块地板,地板不能打碎,但铺的时候可以超过广场大小(1<=n,m,a<=10^9)
思路:求出广场的每条分别至少需要多少地板,然后相乘,我wa的原因就是,没有考虑到相乘的时候已经超int的范围了。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
typedef unsigned long long UL;
#define MS(x,y) memset(x,y,sizeof(x))
#define rpt(i,l,r) for(int i=l;i<=r;i++)
#define rpd(i,r,l) for(int i=r;i>=l;i--)
LL gcd(LL a,LL b){ return b==0?a:gcd(b,a%b);}
#define N 1000005
int main(){
LL n,m,a;
while(scanf("%I64d%I64d%I64d",&n,&m,&a)!=EOF){
LL x=n/a;
if(n%a!=0) x++;
LL y=m/a;
if(m%a!=0) y++;
printf("%I64d\n",x*y);
}
return 0;
}