Codeforces Gym 100286G Giant Screen 水题

时间:2022-12-01 15:35:11

Problem G.Giant Screen
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/G

Description

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 10 000 inclusive) — 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 (1 ≤ n ≤ 100) — 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 10 000 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.

Sample Input

1024 1024 300 300
3
1024 768 295 270 200
1280 1024 365 301 250
1280 800 350 270 210

Sample Output

250

HINT

题意

给你一个需要的屏幕分辨率和长宽

然后给你n个,让你挑选一种,让你花费最小的价格来达到规定的电视

题解

水题,直接贪心除一下然后取min就吼了

代码:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <ctime>
#include <list>
typedef unsigned char byte;
#define pb push_back
#define input_fast std::ios::sync_with_stdio(false);std::cin.tie(0)
#define local freopen("in.txt","r",stdin)
#define pi acos(-1) using namespace std;
const int maxn = + ;
int rh , rv , sh , sv , n;
typedef struct data
{
int rh , rv , sh , sv , p;
}; int Caculate(int x,int y)
{
int num = x / y;
if (y * num < x) num ++;
return num;
} data A[maxn]; int main(int argc,char *argv[])
{
freopen("giant.in","r",stdin);
freopen("giant.out","w",stdout);
scanf("%d%d%d%d%d",&rh,&rv,&sh,&sv,&n);
for(int i = ; i < n ; ++ i) scanf("%d%d%d%d%d",&A[i].rh,&A[i].rv,&A[i].sh,&A[i].sv,&A[i].p);
long long ans = 1LL << ;
for(int i = ; i < n ; ++ i)
{
int s1 = max(Caculate(rh,A[i].rh) , Caculate(sh,A[i].sh));
int s2 = max(Caculate(rv,A[i].rv),Caculate(sv,A[i].sv));
ans = min(ans ,1LL * (long long) s1 * (long long)s2 * (long long)A[i].p );
s1 = max(Caculate(rh,A[i].rv) , Caculate(sh,A[i].sv));
s2 = max(Caculate(rv,A[i].rh),Caculate(sv,A[i].sh));
ans = min(ans ,1LL * (long long) s1 * (long long)s2 * (long long)A[i].p );
}
cout << ans <<endl;
return ;
}

Codeforces Gym 100286G Giant Screen 水题的更多相关文章

  1. Codeforces gym 100685 C&period; Cinderella 水题

    C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...

  2. Codeforces Gym 100431D Bubble Sort 水题乱搞

    原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-an ...

  3. Codeforces GYM 100114 B&period; Island 水题

    B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...

  4. codeforces 577B B&period; Modulo Sum&lpar;水题&rpar;

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round &num;367 &lpar;Div&period; 2&rpar;---水题 &vert; dp &vert; 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  6. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  7. CodeForces 589I Lottery &lpar;暴力,水题&rpar;

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  8. codeforces 710A A&period; King Moves&lpar;水题&rpar;

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

  9. codeforces 659A A&period; Round House&lpar;水题&rpar;

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. NetworkComms V3 之发送UDP广播消息

    NetworkComms网络通信框架序言 NetworkComms通信框架,是一款来自英国的c#语言编写的通信框架,历时6年研发,成熟稳定,性能可靠. NetworkComms v3目前只支持基本的U ...

  2. java nio 网络框架

    https://github.com/solq360/common 主要运行在android 平台 解决自动化编/解码,等等.. 模块 解决问题/实现处理 备注 负责人 进度 录音播放 AudioRe ...

  3. cxf客户端代码wsdlLocation设置相对路径

    利用工生成的cxf客户端代码,wsdlLocation都是绝对路径,为了便于项目更加灵活管理,我们可以将该路径设置为相对路径: 1.下面图片是我的项目路径图片及wsdl地址存放路径: 2.下面图片是我 ...

  4. ViewPager 详解(一)---基本入门

    前言:这两天研究研究ViewPager滚动功能,现在很多的app都有用到这个功能,我们的大虾米也有这个模块.要研究就彻底的研究研究,我从不满足于一个功能只是简单的应用,要学就学的彻底,所以我打算将Vi ...

  5. 用matlab画两个曲面的图

    求助!!用matlab画两个曲面的图 这是我写的程序,但是运行不出来,麻烦帮我修改一下,谢谢!!clearallcloseall[x,y]=meshgrid(0:.1:60);z1=(25*y-25* ...

  6. python django day 5 database 1

    from django.db import models class Blog(models.Model): name = models.CharField(max_length=) tagline ...

  7. hadoop商业版本的选择介绍

    记得刚接触到hadoop的时候跟大部分人一样都会抱怨hadoop的安装部署问题,对于一个新手来说这这的是个头疼的问题,可能需要花费一整天的时间才能把分布式环境安装配置好.在刚接触hadoop的一段时间 ...

  8. 解决 https 证书验证不通过的问题

    解决的办法:忽略服务端和客户端的证书校验即可.java 提供的相关的类. 通过重写TrustManager的checkClientTrusted(检查客户端证书信任)和checkServerTrust ...

  9. Rsyslog配置文件详解&lpar;转&rpar;

    最近在搭建日志审计服务器,使用了rsyslog,发现这篇文章很有用,收藏一下. 原文链接:http://my.oschina.net/0757/blog/198329 具体内容: 非常详细的rsysl ...

  10. vs code 插件推荐

    通用插件 HTML Snippets 超级实用且初级的 H5代码片段以及提示 HTML CSS Support 让 html 标签上写class 智能提示当前项目所支持的样式新版已经支持scss文件检 ...