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;
    }
  • 相关阅读:
    Windows 服务的安装(1)
    C#编写window服务,一步一步(1)
    .net 读写记事本文件
    C#中POST数据和接收的几种方式(抛砖引玉)
    Newtonsoft.Json 通过 JObject 读取 json对像 超简单
    Winform读写App.config文件以及重启程序
    WebMatrix之WebMatrix.Data
    C#中方法的参数的四种类型
    zh-Hans vs.net 通过 管理nuget程序包下载简体中文语言包 zh-cn
    .net C# 图片转Base64 Base64转图片
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5199553.html
Copyright © 2011-2022 走看看