Jzoj 5536. 2014 Dongguan selected game water problem

Source: Internet
Author: User

Description

Small h is a person who likes to think, so he is also very happy to challenge various thinking topics. Today, his friend small L came to him to play, while small l also brought a simple game, small l gave a piece of paper divided into WxH cell, and then told Small H, now requires small h with wxh of paper (not allowed to rotate) on the sheet, ask the small H up to put how many pieces of paper, So that no two pieces of paper overlap.
Of course, this simple problem is quickly solved by small H, now like to think of a small h think of another game, is to let small l to put the paper, but asked small l put the least amount of paper, so small h even put more than a piece of space is not.

Figure 1 is the optimal placement method, Figure 2 is the disallowed placement method (because you can also place one), and Figure 3 is a permissible but not optimal placement method
Small h in order to make the problem interesting, the small l must be placed in parallel to the edge of the paper, and the position of the pieces can be placed on the real point, but not beyond the paper.

Input

The input file contains four integers w,h,wh length, width, length, width of paper, w<=w, H<=h, respectively.

Output

Output a number indicating the minimum number of requirements that can be placed

Sample Input

Sample 1
11 4 3 2

Sample 2
10 8 3 4

Sample 3
15 7 4 2

Sample Output

Sample 1
2

Sample 2
2

Sample 3
4

Data Constraint

70% of Data w<=100,h<=100
100% of Data w<=30000,h<=30000

Analysis:
For the row, place an x rectangle, which is obviously the first empty x-limit, and then put a x,limit for infinity close to 0. That is, a cycle can be regarded as 2x, the w/(2x), if the remainder is greater than or equal to X, that is, can also plug one, add one. Column.

Code:

#include <iostream>
#include <cstdio>

using namespace std;

int k,p,x,y,a,b;

int main ()
{
    freopen ("game.in", "R", stdin);
    Freopen ("Game.out", "w", stdout);
    scanf ("%d%d%d%d", &x,&y,&a,&b);
    int a=a*2; 
    int b=b*2;
    if (x%a>=a) k=x/a+1;
             else k=x/a;
    if (y%b>=b) p=y/b+1;
             else p=y/b;         
    int ans=k*p;         
    printf ("%d", ans);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.