Codeforces Gym100286G Giant Screen (暴力)

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 (1n100) — the number of different screen types available to you. The next n lines contain descriptions of the available screen types. Each description occupies one line and consists of five integer numbers — rh,i,rv,i,sh,i,sv,i,pi (all from
100 to 10000 inclusive), where first four numbers are horizontal and vertical resolution and horizontal and vertical size of ith 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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值