CodeForce:16C-Monitor
传送门:http://codeforces.com/problemset/problem/16/C
Monitor
time limit per test0.5 second
memory limit per test64 megabytes
Problem Description
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That’s why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can’t be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples input
800 600 4 3
1920 1200 16 9
1 1 1 2
Examples output
800 600
1920 1080
0 0
解题心得:
- 题意就是给你一个矩形长为a,宽为b,要你将这个矩形减掉一部分变成长宽比例为x:y,并且要求面积尽可能的大,要求你输出改变后的矩形的长和宽。
- 这个题真的很简单,不需要你去将什么长宽调换什么的,就老老实实的按照题意来就可以了。先将x:y变成最简比例,然后a向x缩,b向y缩,两方同时达到要求就停止。用数学方法实现就行了。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int num[maxn];
long long a,b,x,y;
int main()
{
while(cin>>a>>b>>x>>y)
{
int t=__gcd(x,y);
x/=t;
y/=t;
t=min(a/x,b/y);//要两个边都同时到达比例才行
long long l1,l2;
l1 = x*t;
l2 = y*t;
printf("%lld %lld\n",l1,l2);
}
return 0;
}
CodeForce:16C-Monitor的更多相关文章
- 杂项-Java:Druod Monitor
ylbtech-杂项-Java:Druid Monitor 1.返回顶部 1. https://www.cnblogs.com/wanghuijie/p/druid_monitor.html 2. 2 ...
- 11g新特性:Health Monitor Checks
一.什么是Health Monitor ChecksHealth Monitor Checks能够发现文件损坏,物理.逻辑块损坏,undo.redo损坏,数据字典损坏等等.Health Monitor ...
- mysql:innodb monitor(show engine innodb status)探秘
在旧的版本里面是show innodb status命令,新版本后改动了一些:show engine innodb status; 我们最熟悉的,应当就是show innodb status命令,可以 ...
- DB2 性能分析工具介绍:Event Monitor 篇(转)
https://www.ibm.com/developerworks/cn/data/library/techarticle/dm-1112qiaob/ 引言 DB2 提供了两个比较常用的数据库性能分 ...
- 文档翻译第003篇:Process Monitor帮助文档(Part 3,附Process Monitor的简单演示)
[导入与导出配置] 一旦您配置了一个筛选器,您能够使用"工具(Tools)"菜单中的"保存筛选器(SaveFilters)"菜单项将其保存.Process Mo ...
- 文档翻译第001篇:Process Monitor帮助文档(Part 1)
[译者注] Process Monitor是一款非常著名的系统进程监视软件.总体来说,Process Monitor相当于Filemon+Regmon,其中的Filemon专门用来监视系统中所有文件的 ...
- 文件翻译002片:Process Monitor帮助文档(Part 2)
[筛选亮点] Process Monitor提供了一些方式来配置筛选器和高亮显示. 筛选器的包括与排除 您能够在筛选器中指定事件的属性,这样就能够令Process Monitor仅显示 ...
- CodeForce:732B-Cormen — The Best Friend Of a Man
传送门:http://codeforces.com/problemset/problem/732/B Cormen - The Best Friend Of a Man time limit per ...
- Spring Boot :Druid Monitor
忙里偷个闲,在这里分享一下SpringBoot集成Druid实现数据库监控功能,有什么错误欢迎大家指出! 参考文件: Spring实现Druid监控:https://www.cnblogs.com/w ...
随机推荐
- 举例实用详解sc.textFile()和wholeTextFiles()
谈清楚区别,说明白道理,从案例开始: 1 数据准备 用hdfs存放数据,且结合的hue上传准备的数据,我的hue截图: 每个文件下的数据: 以上是3个文件的数据,每一行用英文下的空格隔开: 2 测试 ...
- 单台服务器最大tcp连接
如果对服务器进行压力测试,常常出现这种情况 tcp连接数过多 netstat -an windows查看tcp连接数 那么怎么增加单台服务器的最大连接数呢? 最简单的办法,增加内 ...
- CentOS7.5安装JDK1.8
1.准备JDK安装包 [1]查看环境 cat /etc/redhat-release [2]下载JDK1.8 网址: https://www.oracle.com/technetwork/java/j ...
- P3818 小A和uim之大逃离 II
题目背景 话说上回……还是参见 https://www.luogu.org/problem/show?pid=1373 吧 小a和uim再次来到雨林中探险.突然一阵南风吹来,一片乌云从南部天边急涌过来 ...
- There is much opportunity for anyone willing to dedicate himself to his labors.
There is much opportunity for anyone willing to dedicate himself to his labors.付出努力的人才有机会出人头地.
- Kendo MVVM 数据绑定(八) Style
Kendo MVVM 数据绑定(八) Style Style 绑定可以通过 ViewModel 绑定到 DOM 元素 CSS 风格属性,例如: <span data-bind="sty ...
- linux 查看dd进度
Linux下显示dd命令的进度: dd if=/dev/zero of=/tmp/zero.img bs=10M count=100000 想要查看上面的dd命令的执行进度,可以使用下面几种方法: 比 ...
- iOS 应用架构 (三)
iOS 客户端应用架构看似简单,但实际上要考虑的事情不少.本文作者将以系列文章的形式来回答 iOS 应用架构中的种种问题,本文是其中的第二篇,主要讲 View 层的组织和调用方案.下篇主要讨论做 Vi ...
- 【extjs6学习笔记】1.5 初始:关于布局
absolute 绝对布局,这个布局使用 x 和 y 属性来指定组件的绝对定位 accordion 手风琴布局[可折叠布局]这个布局展示了在一个时间里只有一个内置的可支持折叠和展开的子级 panel ...
- 为什么HDFS的副本数通常选择3?
HDFS采用一种称为机架感知的策略来改进数据的可靠性.可用性和网络带宽的利用率. 在大多数情况下,HDFS的副本系数是3,HDFS的存放策略是一个副本存放在本地机架节点上,另一个副本存放在同一机架的另 ...