E - Theatre Square

E - Theatre Square

一个城市的广场面积有 N×M平方米,过段时间,恰逢这个城市的庆典活动,主办方决定在广场上铺设一种新的地砖,这种地砖每块都是a×a平方米的。
那么问题来了,最少需要多少地砖才能铺满整个广场呢?地砖一定要把广场铺满,允许地砖面积可以超过广场,同时,铺地砖的时候地砖的边必须和广场的边是平行的。

Input
输入数据包含三个正整数n,m,a(1 ≤  n, m, a ≤ 1000000000).

Output
输出最少的地砖数量。

Sample Input
6 6 4

Sample Output
4

注意数据溢出!注意数据溢出!注意数据溢出!

代码:

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner reader =new Scanner(System.in);
		BigInteger n,m,a;
		n=reader.nextBigInteger();
		m=reader.nextBigInteger();
		a=reader.nextBigInteger();	
		BigInteger t1,t2,l,t;  
		t1=BigInteger.ONE;
		t2=BigInteger.ONE;
		l=BigInteger.ONE;
		t=BigInteger.ZERO;
		if((n.mod(a)).equals(t)==false)
			t1=(n.divide(a)).add(l);
		else
			t1=n.divide(a);
		if((m.mod(a)).equals(t)==false)
			t2=(m.divide(a)).add(l);
		else
			t2=m.divide(a);
		System.out.println(t1.multiply(t2));
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值