Codeforces Gym 100269G Garage 数学
2016-02-18 23:06
441 查看
Garage
题目连接:
http://codeforces.com/gym/100269/attachmentsDescription
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 mayassume that 1 ≤ w ≤ W ≤ 30 000 and 1 ≤ h ≤ H ≤ 30 000.
Output
Output the optimal number of garages.Sample Input
15 7 4 2Sample Output
4Hint
题意
现在给你一个矩形,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; }
相关文章推荐
- 当模版类遇上友元函数
- 数据类型
- 读书笔记 -《Python 黑帽子》 ( 一 )
- 处理XSS漏洞的工具类代码
- react-native启动异常,react-deep-force-update/.babelrc
- 《招聘一个靠谱的 iOS》—参考答案(下)
- 面试1--HashMap跟Hashtable之间的区别
- 4--静态链表
- 七牛云存储刷新缓存
- 归档备份
- 自己动手丰衣足食之移动端日期选择插件
- android raw与assets区别
- 配置webstorm监听less时时转换
- Javascript自学-4
- WP的后台代理
- WP的后台代理
- 定时器和多线程的不同
- c#实现每隔一段时间执行代码(多线程)
- Java中static关键字的作用和用法详细介绍
- [深入理解JAVA虚拟机-JDK1.7]-[调优案例分析]-1[高性能硬件部署]