UVALive - Movie

news/2025/3/28 7:49:07/

题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4755
Time limit: 3000 ms

Problem Description

The “Last ACM Contest” movie has been recently released and got the record of the highest worldwide gross. Gabby has been so busy due to his practicing for the ACM programming contest in Tehran site and hence, he has not succeeded to watch the movie at a cinema. Like many other people, he has legally downloaded the movie to watch it using a smart phone or a tablet on the way back home from the Sharif University on 20 December 2013, the contest day. Unfortunately, he has neither a smart phone nor a tablet. He therefore has decided to buy a device from the following smart phones or tablets that are available in the market.

DevicePriceResolution
iPad Mini3191024 × 768
Galaxy Tab4191024 × 600
iPhone 4S450960 × 640
iPad45192048 × 1536
iPhone 5C5991136 × 640
Galaxy Tab26001280 × 800
Galaxy S46301080 × 1920
iPhone 5S7191136 × 640

As you can see, each device has a known “height × width” resolution which is the number of distinct pixels in each dimension that can be displayed. Like the above devices, each movie has a known resolution H × W and video players equally scale both dimensions of the movie resolution by a factor of c to display it in a [cH] × [cW] window where [x] is the largest integer not greater than x and c is a rational number such that cH and cW are not greater than the height and width resolutions of the display, respectively. Indeed, video players zoom a movie in or out while preserving the aspect ratio (the ratio of the height resolution to the width resolution) of the movie. When a video player displays a movie in the full-screen window in a device, some parts of the device display may remain “blank” (or unused) due to the difference in the aspect ratios of the device display and the movie. For a movie resolution and a display resolution, the usage ratio is defined to be the ratio of the non-blank
area of the full-screen video-player window showing the movie to the area of the device display. As all above devices can rotate the whole screen 90 degrees, they may increase their usage ratio for a movie. For instance, if the movie resolution is 720 × 480, the usage ratio of iPad4 is the maximum of (2048 ∗ 1365)/(2048 ∗ 1536) and (1536 ∗ 1024)/(1536 ∗ 2048) (the latter is due to a 90-degree rotation) which is 1365/1536.
Gabby is now looking for a device with the highest usage ratio for the “Last ACM Contest” movie which is stored with the resolution H × W. He kindly asks you to report him this device before the end of the contest.

Input

There are multiple test cases in the input. Each test case consists of a line containing two integers 1 ≤ H, W ≤ 5000 which is the resolution of the “Last ACM Contest” movie. The input terminates with ‘0 0’ which should not be processed.

Output

For each test case, output a line containing the price of the device which has the highest usage ratio
for the given movie resolution. In case of a tie, output the smallest price. For example, if both iPad4
and iPad Mini have the highest usage ratio, output 319.

Sample Input

720 480
640 320
800 600
2500 2500
0 0

Sample Output

450
630
319
319

Problem solving report:

Description:有8种设备供你选择,求出其中最大的屏幕使用率。
Problem solving:一个个的判断就行了,设备可旋转使用,注意精度问题。

Accepted Code:

/* * @Author: lzyws739307453 * @Language: C++ */
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
struct edge {int v, h, w;
}p[] = {{319, 1024, 768},{419, 1024, 600},{450, 960, 640},{519, 2048, 1536},{599, 1136, 640},{600, 1280, 800},{630, 1080, 1920},{719, 1136, 640}};
double slove(int h, int w, int x, int y) {double ans1 = 1.0 * x / h;double ans2 = 1.0 * y / w;ans1 = min(ans1, ans2);int hh = h * ans1 + eps, ww = w * ans1 + eps;return 1.0 * ww * hh / (x * y);
}
int main() {int h, w;while (scanf("%d%d", &h, &w), h + w) {int cnt = 0;double max_ = 0;for (int i = 0; i < 8; i++) {double tmp = max(slove(h, w, p[i].h, p[i].w), slove(w, h, p[i].h, p[i].w));if (tmp - max_ > eps) {max_ = tmp;cnt = p[i].v;}else if (fabs(tmp - max_) < eps)cnt = min(cnt, p[i].v);}printf("%d\n", cnt);}return 0;
}

http://www.ppmy.cn/news/409867.html

相关文章

UI/UE

1 界面设计原则 1.1 UX与UI设计基础 UI设计是指对软件的人机交互、操作逻辑、界面美观的整体设计。其中近年来用户体验&#xff08;UX/UE&#xff09;渐渐的成为产品设计的重点。 用户体验&#xff08;UX/UE&#xff09;是一种纯主观在用户使用产…

Linux | Vi/Vim 编辑器

1 模式 三种模式 正常模式&#xff1a;正常模式&#xff0c;默认模式&#xff0c;阅读处理文件内容插入模式&#xff1a;编辑模式&#xff0c;编辑字符命令行模式&#xff1a;整个文件的操作 模式的转换 2 快捷键/指令 ​​​​​​​​​​​​​​ 模式指令作用vi 文件名…

IL指令集

IL是.NET框架中中间语言&#xff08;Intermediate Language&#xff09;的缩写。使用.NET框架提供的编译器可以直接将源程序编译为.exe或.dll文件&#xff0c;但此时编译出来的程序代码并不是CPU能直接执行的机器代码&#xff0c;而是一种中间语言IL&#xff08;Intermediate L…

Linux-11-vi/vim编辑器

vim编辑器的三种工作模式 命令模式&#xff08;Command mode&#xff09; 命令模式是vim的中心。 命令模式下&#xff0c;所敲的按键编辑器都理解为命令&#xff0c;以命令驱动执行不同的功能。 此模型下&#xff0c;不能自由进行文本编辑。 输入模式&#xff08;Insert mode&…

LVGL|基于lvgl 7.11.0 编写的 IMX6ULL Linux lvgl GUI,支持OTA远程升级!

文章目录 项目概览硬件选择为开发板支持OTA远程自动升级我们实现了如下两种方式如何使用 不想使用镜像&#xff0c;只要源码LVGL中文手册 项目概览 IMX6ULL LVGL GUI V1.0演示 基于 800x600的LCD屏幕上开发&#xff0c;去年就已经完成由于其他项目闲置了很久&#xff0c;当时使…

Linux IVI软件简介

说明 Linux IVI软件由个人开发&#xff0c;拥有自主知识产权。即可作为量产IVI产品用也可用于linux嵌入式开发项目学习用。 后续会对各个模块进行技术说明&#xff0c;开放部分资料和代码下载&#xff0c;寻求合作、培训和转让&#xff0c;欢迎私信&#xff0c;微信号&#x…

imul和idiv指令

imul 有符号乘法指令&#xff0c;分单操作数&#xff0c;双操作数和但操作数 单操作数&#xff1a;此形式与mul指令使用完全相同&#xff0c;操作数乘以al、ax、或eax寄存器中的值&#xff0c;乘积分别存储到ax、dx&#xff1a;ax或edx&#xff1a;eax中 执行指令&#xff1a…

Global Illumination_Light Propagation Volumes (LPV)

文章具体参照 https://ericpolman.com/ 本方法的思想就是把场景分成很多的小格子&#xff0c;然后计算每一个小格子里面的光照&#xff08;LPV&#xff09;。如果直接计算每个格子里面的光照那代价也是不可接受的&#xff0c;因此本算法用了一种很巧妙的方式来处理&#xff1…