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 ...
随机推荐
- 【WEB小工具】jQuery函数
jQuery-API帮助文档:Click here jQuery简介 jQuery是JavaScript框架,jQuery也是JavaScript代码.使用jQuery要比直接使用JavaScript ...
- Android 使用Instrumentation进行界面的单元测试
如果我们要对一个Activity界面上的一个按钮的点击事件进行单元测试,则可使用ActivityInstrumentationTestCase2类来进行测试. 首先我们定义一个测试类: public ...
- java web 学习九(通过servlet生成验证码图片)
一.BufferedImage类介绍 生成验证码图片主要用到了一个BufferedImage类,如下:
- Android:实现一种浮动选择菜单的效果
总结如何实现Android浮动层,主要是dialog的使用. 自定义一个类继承自Dialog类,然后在构造方法中,定义这个dialog的布局和一些初始化信息. 案例1: public class Me ...
- strcpy函数和strncpy函数的区别
strcpy函数和strncpy函数的原型介绍在我的另一篇文章中介绍了,见strcpy,strncpy,strlen等函数原型 strcpy:字串复制 原型:char *strcpy(char *de ...
- ORACLE临时表总结[转]
临时表概念 临时表就是用来暂时保存临时数据(亦或叫中间数据)的一个数据库对象,它和普通表有些类似,然而又有很大区别.它只能存储在临时表空间,而非用户的表空间.ORACLE临时表是会话或事务级别的,只对 ...
- STM32查看系统时钟
调用库函数RCC_GetClocksFreq,该函数可以返回片上的各种时钟的频率 函数原形 void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clock ...
- C++实现网格水印之调试笔记(一)
首先说一下我的一些简单的调试方法,除了常规的断点调试之外,我还会使用注释的方法来调试.当整个工程代码量相当多且调用层次关系较为复杂时,这种方法能够比较高效的定位到出错误的代码段或某个函数,然后在出现错 ...
- 【原】Storm实战
3.Storm实战 如何新建一个Storm 项目 本文简要概括如何新建一个Storm项目,步骤如下: 1.添加Storm 相关jar添加到类路径上. 2.如果使用多语言特性,将多语言实现的目录加到cl ...
- nodejs写的一个网页爬虫例子(坏链率)
因为工作需要,用nodejs写了个简单的爬虫例子,之前也没用过nodejs,连搭环境加写大概用了5天左右,so...要多简陋有多简陋,放这里给以后的自己看~~ 整体需求是:给一个有效的URL地址,返回 ...