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

    参考文档 :RTX51 Tiny 2.02 中文手册.doc.Keil_Rtx51_tiny_RTOS中文版.pdf RTX-51 有 2 个版本:Full 和 Tiny.类似的国人写的 Small ...

  2. (转)nginx限制上传大小和超时时间设置说明/php限制上传大小

    nginx限制上传大小和超时时间设置说明/php限制上传大小 原文:http://www.cnblogs.com/kevingrace/p/6093671.html 现象说明:在服务器上部署了一套后台 ...

  3. log4j.properties错误及配置详解

    当在Eclipse上运行MapReduce程序遇到以上问题时,请检查项目中是否有log4j.properties配置文件,或者配置文件是否正确. 刚接触Hadoop的时候不太了解log4j.prope ...

  4. windows无法启动redis服务,错误码1067

    https://blog.csdn.net/kissdead0xzy/article/details/84332870

  5. java 通用查询框架Querydsl 简介

    Querydsl 是一个通用的查询框架,专注于通过JavaAPI构建类型安全的SQL查询说说Querydsl的优势吧: 1. Querydsl支持代码自动完成,因为才纯Java API编写查询,因此主 ...

  6. tomcat调优方案Maximum number of threads (200) created for connector with address null and port 8091

    1.tomcat6大并发出现:INFO: Maximum number of threads (200) created for connector with address null and por ...

  7. Redhat/CentOS 软件安装

    概述 软件包简介 rpm 包安装 yum 在线安装 源码包管理 软件包分类 源码包 二进制包(rpm包.系统默认包) rpm包安装 rpm包的依赖性 树形依赖: a -> b -> c 环 ...

  8. 【Unity3D】3D游戏学习

    1.理解游戏元素,简单回答以下问题: 1.1简单介绍一款上世纪(19XX)出品的计算机游戏,然后按课件的方法描述游戏的五个基本元素.(讲目标.玩法.规则) 1.1.1仙剑奇侠传 <仙剑奇侠传&g ...

  9. R语言笔记2

    <13: Simulation> > sample(1:6,4,replace=TRUE) [1] 4 5 2 6 在1-6的整数中随机生成4个整数,且数字可以重复,即每个数字均可重 ...

  10. Android(java)学习笔记136:利用谷歌API对数据库增删改查(推荐使用)

    接下来我们通过项目案例来介绍:这个利用谷歌API对数据库增删改查 1. 首先项目图: 2. 这里的布局文件activity_main.xml: <LinearLayout xmlns:andro ...