zoukankan      html  css  js  c++  java
  • Codeforces Gym 100269G Garage 数学

    Garage

    题目连接:

    http://codeforces.com/gym/100269/attachments

    Description

    Wow! What a lucky day! Your company has just won a social contract for building a garage complex.
    Almost all formalities are done: contract payment is already transferred to your account.
    So now it is the right time to read the contract. Okay, there is a sandlot in the form of W × H rectangle
    and you have to place some garages there. Garages are w × h rectangles and their edges must be parallel
    to the corresponding edges of the sandlot (you may not rotate garages, even by 90◦
    ). The coordinates of
    garages may be non-integer.
    You know that the economy must be economical, so you decided to place as few garages as possible.
    Unfortunately, there is an opposite requirement in the contract: placing maximum possible number of
    garages.
    Now let’s see how these requirements are checked. . . The plan is accepted if it is impossible to add a new
    garage without moving the other garages (the new garage must also have edges parallel to corresponding
    sandlot edges).
    Accepted optimal plan Rejected plan Accepted, but non-optimal plan
    Time is money, find the minimal number of garages that must be ordered, so that you can place them
    on the sandlot and there is no place for an extra garage.

    Input

    The only line contains four integers: W, H, w, h — dimensions of sandlot and garage in meters. You may
    assume that 1 ≤ w ≤ W ≤ 30 000 and 1 ≤ h ≤ H ≤ 30 000.

    Output

    Output the optimal number of garages.

    Sample Input

    15 7 4 2

    Sample Output

    4

    Hint

    题意

    现在给你一个矩形,W*H的,然后问你最少个w*h的小矩形

    题解:

    想一想

    一个小矩形最多可以占据2*w*2*h的空间嘛

    然后我们直接暴力算就好了,注意最后如果还有空位的话,就直接放一个进去就好了

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        freopen("garage.in","r",stdin);
        freopen("garage.out","w",stdout);
        long long W,H,w,h;
        cin>>W>>H>>w>>h;
        long long L,R,l,r;
        L = W/w/2+W/w%2;
        R = H/h/2+H/h%2;
        cout<<L*R<<endl;
    }
  • 相关阅读:
    第一次作业
    机器学习第一次个人作业
    第02组 Beta版本演示
    第02组 Beta冲刺(4/4)
    第02组 Beta冲刺(3/4)
    微信小程序信息会话列表删除功能
    微信小程序自定义弹窗组件
    微信小程序使用Echarts
    uni.showModal,uni.showToast使用
    Array filter() 方法
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5199553.html
Copyright © 2011-2022 走看看