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 ...
随机推荐
- source insight 的使用
一,新建工程:project-->new project --> ok--> ok--> close 完成项目的添加 二,sourceInsight的使用 1.跳转到标识定义处 ...
- 对delegate进行扩展 打造通用的"计时完成"方法 z
让用户尽量少打字 每次让用户输入这么多信息的确很糟糕, 可以改进一下设计: 服务器IP和用户名可以存放在配置文件里面, 初始化的时候默认加载到相应的文本框中; 从安全角度考虑, 密码必须经过用户手动输 ...
- 在Ubuntu下卸载Apache
卸载Apache 转自:http://blog.csdn.net/chmo2011/article/details/7026384 1. 删除apache 代码: $ sudo apt-get --p ...
- HDU5790 Prefix 字典树+主席树
分析:这个题和spoj的d_query是一个题,那个是求一段区间里有多少个不同的数字,这里是统计有多少个不同的前缀 用字典树进行判重,(和查询不同的数字一样)对于每个不同的前缀,只保留它最后一次出现的 ...
- Chrome的网络调试
F12 然后
- Unity3d 基于物理渲染Physically-Based Rendering之specular BRDF
在实时渲染中Physically-Based Rendering(PBR)中文为基于物理的渲染它能为渲染的物体带来更真实的效果,而且能量守恒 稍微解释一下字母的意思,为对后文的理解有帮助,从右到左L为 ...
- auto printer 自动打字机效果
前段时间在知乎上看到了一个打字机的效果,所以,心血来潮,自己也来写了一个打字机的效果. 比较简单,但还有待优化的地方,因为自己感觉这个效果不够炫,等哪天想出好的点子了.再来更新…… 代码效果预览地址: ...
- 浅谈JavaScript中的原型模式
在JavaScript中创建对象由很多种方式,如工厂模式.构造函数模式.原型模式等: <pre name="code" class="html">/ ...
- web服务器分析与设计(二)
面向对象分析与设计第二步:寻找对象,建立问题域模型 1,用例场景描述 接上一篇中的用例,编写用例场景 U1: 上网者:打开网站(www.xxx.com) 浏览器:连接网站 目标系统:接受连接 检查连接 ...
- markdown常用html标签
换行 测试<br />一下 效果:测试一下 标记 <mark>测试一下</mark> 效果:测试一下 空格 测试一下 效果: 测试一下 ...