Codeforces Gym 100286G Giant Screen 水题
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 水题的更多相关文章
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
- Codeforces Gym 100431D Bubble Sort 水题乱搞
原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-an ...
- Codeforces GYM 100114 B. Island 水题
B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- TCP/IP详解学习笔记(14)-TCP连接的未来和性能(未写完)
在TCP刚出世的时候,其主要工作环境是以太网和SLIP之类的低速网络.随着高速网络的出现,让TCP协议的吞吐量更大,效率更高的要求就愈来愈迫切.为此,TCP增加了三个重要机制来对应现在的变化,他们是 ...
- vim简单使用教程
vim的学习曲线相当的大(参看各种文本编辑器的学习曲线),所以,如果你一开始看到的是一大堆VIM的命令分类,你一定会对这个编辑器失去兴趣的.下面的文章翻译自<Learn Vim Progress ...
- DevExpress控件XtraGrid的Master-Detail用法 z
XtraGrid支持Master-Detail展示,在自带的Demo中展示了一个“公司——产品——订单”的例子.自己照着实现了一下,有几处关键地方补充一下. 示例: 部门信息(主1)——部门下用户(从 ...
- HDU 2227-Find the nondecreasing subsequences(dp+BIT优化)
题意: 给你一个序列a[],求它的不降子序列的个数 分析: dp[i]表示以i结尾不降子序列的个数,dp[i]=sum(dp[j])+1(j<i&&a[j]<=a[i]); ...
- Windows7 64位系统下无法安装网络打印机的解决方法
背景: 公司一台HP LaserJet 1010 打印机连在一台Windows XP的电脑上,而我的是windows7 64位系统,无法安装驱动解决办法:1:去惠普官网上下载对应的64位驱动(什么Vi ...
- auto printer 自动打字机效果
前段时间在知乎上看到了一个打字机的效果,所以,心血来潮,自己也来写了一个打字机的效果. 比较简单,但还有待优化的地方,因为自己感觉这个效果不够炫,等哪天想出好的点子了.再来更新…… 代码效果预览地址: ...
- 测试xss和xsf
xss注入攻击: 123123123 被动注入: 1231231231231231 主动注入: 对不起,你需要登录才能评论 用户名 密码
- mvc JavaScriptResult的用法
一.JavaScriptResult在MVC中的定义的代码片段 C# 代码 复制 public class JavaScriptResult : ActionResult { public o ...
- HTML 5:绘制旋转的太极图
HTML: <!DOCTYPE> <html> <head> <meta charset="utf-8" /> <title& ...
- 微信公众平台开发 ACCESS TOKEN
获取access token 返回 access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token.正常情况下access_token有效期为7200秒,重复获取将 ...