弱校联萌十一大决战之如日中天 G Gadget Hackwrench

Input/Output: standard input/output

Chip 'n' Dale have started a new business in the forest: they produce tiles of fixed rectangular size and pave roads with them.

Road paving rules are the following. Starting from one corner of the rectangular road tiles are paved side-by-side without gaps or overlaps. Tiles can be cut into pieces to be used to pave the road if and only if the whole tile doesn't fit. Each tile contains a pattern with parallel lines that must be retained on the paved road. This makes their orientation significant: any tile or its piece can not be rotated. All tile connection lines are straight, parallel to one of the road edges and either perpendicular or parallel to each other. Chip 'n' Dale always pave the road so that each edge of a tile is adjacent to not more than one other tile, and they always pave the road with the least possible amount of tile pieces on the road.

Given the size of the road and the size of one tile please help Chip 'n' Dale determine the number of tiles they need to produce to fully pave the road.

Input

On the first line of input integers Widthroad and Lengthroad (1 ≤ Widthroad, Lengthroad ≤ 10 000) are given — the width and the length of the road respectively.

On the second line of input integers Widthtile and Lengthtile (1 ≤ Widthtile ≤ Widthroad1 ≤ Lengthtile ≤ Lengthroad) are given — the width and the length of the tile respectively.

Output

The first line of the output should contain a single integer number N — the minimal number of whole tiles needed to fully pave the road according to Chip 'n' Dale road paving rules.

Sample Input

Input
10 10
2 2
Output
25
Input
3 5
2 2
Output
4
Input
35 17
25 1
Output
26
 
  
链接

可惜了我久违的!A啊啊啊啊 时间不够了 没写完T^T 题意当中有个点 学弟读题没读出来 就是只能长边对长边 短边对短边!而且不能转 实在不行了才能裁  

我读题还以为边角废料能凑在一起 后来学弟说要真能那么做 都裁成1x1的多好  哈哈 水题一个 就是一顿分类讨论 我丑陋的代码==

#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int x,y,a,b;
int main()
{
   // freopen("cin.txt","r",stdin);
    while(~scanf("%d%d",&x,&y))
    {
        scanf("%d%d",&a,&b);
        int sum=0;
        sum+=((x/a)*(y/b));
       // printf("%d\n",sum);
        if((x%a==0)&&(y%b==0))
        {
            printf("%d\n",sum);
            continue;
        }
        int ans1=x%a,ans2=y%b;
       // printf("%d %d\n",ans1,ans2);
        if(ans1==0)
        {
            if(ans2>(b)/2)
            {
                sum+=(x/a);
                printf("%d\n",sum);
            }
            else
            {
                int tmp=b/ans2,tmp2=x/a;
                sum+=tmp/tmp2;
                if(tmp2%tmp) sum++;
                 printf("%d\n",sum);
            }
            continue;
        }
        if(ans2==0)
        {
            if(ans1>a/2)
            {
                sum+=y/b;
                printf("%d\n",sum);
            }
            else
            {
                int tmp=a/ans1,tmp2=y/b;
                sum+=tmp2/tmp;
                if(tmp2%tmp) sum++;
                 printf("%d\n",sum);
            }
            continue;
        }
        if(ans1>(a)/2)
        {
            if(ans2>(b)/2)
            {
                sum+=x/a;
                sum+=(y/b+1);
                printf("%d\n",sum);
            }
            else
            {
                sum+=(y/b);
                int tmp=b/ans2;
                sum+=(x/(a*tmp));
                if(x%(a*tmp))sum++;
                 printf("%d\n",sum);
            }
        }
        else
        {
            if(ans2>(b)/2)
            {
                sum+=(x/a);
                int tmp=a/ans1;
                sum+=(y/(b*tmp)+1);
                printf("%d\n",sum);
            }
            else
            {
                int tmp1,tmp2,sum1=0,sum2=0;
                tmp1=y/b,tmp2=a/ans1;
                sum1=tmp1/tmp2;
                if(tmp1%tmp2) sum1++;
                tmp1=b/ans2;
                sum1+=(x/(tmp1*a));
                if(x%(tmp1*a)) sum1++;
                tmp1=x/a,tmp2=b/ans2;
                sum2+=tmp1/tmp2;
                if(tmp1%tmp2) sum2++;
                tmp1=(a/ans1)*b;
                sum2+=(y/tmp1);
                if(y%tmp1) sum2++;
                if(sum1<sum2) sum+=sum1;
                else sum+=sum2;
              //  printf("sum1=%d  sum2=%d\n",sum1,sum2);
                printf("%d\n",sum);
            }
        }
    }
    return 0;
}


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值