Giant Screen
Time Limit:2000MS
Memory Limit:262144KB
You are working in Advanced Computer Monitors (ACM), Inc. The company is building and selling giant computer screens that are composed from multiple smaller screens. Your are responsible for design of the screens for your customers.
Customers order screens of the specified horizontal and vertical resolution in pixels and a specified horizontal and vertical size in millimeters. Your task is to design a screen that has a required resolution in each dimension or more, and has required size in each dimension or more, with a minimal possible price. The giant screen is always built as a grid of monitors of the same type. The total resolution, size, and price of the resulting screen is simply the sum of resolutions, sizes, and prices of the screens it is built from.
You have a choice of regular monitor types that you can order and you know their resolutions, sizes, and prices. The screens of each type can be mounted both vertically and horizontally, but the whole giant screen must be composed of the screens of the same type in the same orientation. You can use as many
screens of the chosen type as you need.
Input
The first line of the input file contains four integer numbers
rh
,
rv
,
sh
, and
sv
(all from
100
to
10000
nclusive) — horizontal and vertical resolution and horizontal and vertical size of the screen you have to build, respectively. The next line contains a single integer number
n
(
100
to
10000
inclusive), where first four numbers are horizontal and vertical resolution and horizontal and vertical size of
i−th
screen type, and
pi
is the price.
Output
Write to the output file a single integer — the minimal price of the specified giant screen.
题意
组装一块屏幕,有多种零件可选,只能选择一种零件进行组装,并且零件方向一致,要求组装好的屏幕水平和竖直方向上的像素数量和尺寸不小于要求的像素数量和尺寸。
题解
数据1到100。。。直接暴力。。需要注意的就是每种零件有两种摆法。。。AC代码如下
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
int ans=(1<<31)-1;
int N;
int x,y,z,w;
int a,b,c,d,p;
int shit,fuck;
int holyfuck;
int main()
{
freopen("giant.in","r",stdin);
freopen("giant.out","w",stdout);
scanf("%d%d%d%d",&x,&y,&z,&w);
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
shit=max(z/c+(z%c?1:0),x/a+(x%a?1:0));
fuck=max(w/d+(w%d?1:0),y/b+(y%b?1:0));
holyfuck=shit*fuck;
shit=max(z/d+(z%d?1:0),x/b+(x%b?1:0));
fuck=max(w/c+(w%c?1:0),y/a+(y%a?1:0));
holyfuck=min(holyfuck,shit*fuck);
ans=min(ans,holyfuck*p);
}
printf("%d\n",ans);
return 0;
}