传送门: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


解题心得:

  1. 题意就是给你一个矩形长为a,宽为b,要你将这个矩形减掉一部分变成长宽比例为x:y,并且要求面积尽可能的大,要求你输出改变后的矩形的长和宽。
  2. 这个题真的很简单,不需要你去将什么长宽调换什么的,就老老实实的按照题意来就可以了。先将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的更多相关文章

  1. 杂项-Java:Druod Monitor

    ylbtech-杂项-Java:Druid Monitor 1.返回顶部 1. https://www.cnblogs.com/wanghuijie/p/druid_monitor.html 2. 2 ...

  2. 11g新特性:Health Monitor Checks

    一.什么是Health Monitor ChecksHealth Monitor Checks能够发现文件损坏,物理.逻辑块损坏,undo.redo损坏,数据字典损坏等等.Health Monitor ...

  3. mysql:innodb monitor(show engine innodb status)探秘

    在旧的版本里面是show innodb status命令,新版本后改动了一些:show engine innodb status; 我们最熟悉的,应当就是show innodb status命令,可以 ...

  4. DB2 性能分析工具介绍:Event Monitor 篇(转)

    https://www.ibm.com/developerworks/cn/data/library/techarticle/dm-1112qiaob/ 引言 DB2 提供了两个比较常用的数据库性能分 ...

  5. 文档翻译第003篇:Process Monitor帮助文档(Part 3,附Process Monitor的简单演示)

    [导入与导出配置] 一旦您配置了一个筛选器,您能够使用"工具(Tools)"菜单中的"保存筛选器(SaveFilters)"菜单项将其保存.Process Mo ...

  6. 文档翻译第001篇:Process Monitor帮助文档(Part 1)

    [译者注] Process Monitor是一款非常著名的系统进程监视软件.总体来说,Process Monitor相当于Filemon+Regmon,其中的Filemon专门用来监视系统中所有文件的 ...

  7. 文件翻译002片:Process Monitor帮助文档(Part 2)

    [筛选亮点] Process Monitor提供了一些方式来配置筛选器和高亮显示.         筛选器的包括与排除 您能够在筛选器中指定事件的属性,这样就能够令Process Monitor仅显示 ...

  8. 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 ...

  9. Spring Boot :Druid Monitor

    忙里偷个闲,在这里分享一下SpringBoot集成Druid实现数据库监控功能,有什么错误欢迎大家指出! 参考文件: Spring实现Druid监控:https://www.cnblogs.com/w ...

随机推荐

  1. github 新建一个分支

    我能说今天在github上新建分支的时候懵逼了半天吗..为了下次不再懵逼,还是在这里记录一下吧.. 进入你的项目---code---Branch----点击那个倒三角-----你会发现一个输入框(这是 ...

  2. (转)io各层次性能汇总及运行速度对比

    io各层次性能汇总:以上图片可以清晰的解释io的运行效率 守护进程:持续保持运行着的程序 进程:放在内存中运行的程序 程序:代码文件,php,java

  3. Redis 基础特性讲解

    目录 1.Redis基础杂项小节 1.是什么 2.能干嘛 3.去哪下 4.Redis启动后基础知识讲解 2.Redis数据类型 1.常用的五大数据类型 2.高级'玩家'才知道的其他数据类型 3.Red ...

  4. AI入门丨开源学习资源推荐

    现在AI大热,网上的资源也非常多,让人眼花缭乱.非科班的我,经过半年的摸索,也算马马虎虎入了坑.下面整理了我认为不错的学习资源,大部分我都看过,以分享给更多的人.我会不断保持更新,也欢迎大家补充. P ...

  5. js页面可视区域懒加载

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 使用 swift3.0高仿新浪微博

    项目地址:https://github.com/SummerHH/swift3.0WeBo 使用 swift3.0 高仿微博,目前以实现的功能有,添加访客视图,用户信息授权,首页数据展示(支持正文中连 ...

  7. Appium基础四:Desired Capabilities详讲

    Desired Capabilities在启动session的时候是必须提供的,先看如下代码: Desired Capabilities本质上是key value的对象,他告诉appium serve ...

  8. linux系统基本结构-《循序渐进linux》

    1.linux控制台 linux系统由桌面控制台(X -Window视窗)和字符控制台组成.字符控制台是linux的核心,默认linux下有6个字符控制台. 字符控制台--〉X-Window下:ctr ...

  9. ios 设置导航栏背景色

    //设置导航栏背景色 如果上面的不好用 就用下面的 [self.navigationController.navigationBar setBackgroundImage:[UIImage image ...

  10. 【extjs6学习笔记】1.6 初始:本地化

    app.json中修改