Monitor

题目描述

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.

输入

The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·10^9).

输出

If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.

示例输入

800 600 4 3

1920 1200 16 9

1 1 1 2

示例输出

800 600

1920 1080

0 0


解题心得:

  1. 一道cf的水题,之前还想多了,写的比较复杂,判断了长和宽,其实没有必要很简单。直接看代码都可以看得懂。但是要注意一点要将x,y的最大公约数给除去,不然得到的不是满足的最大的面积。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b,x,y;
while(scanf("%lld%lld%lld%lld",&a,&b,&x,&y) != EOF)
{
bool flag = false;
ll k = __gcd(x,y);//一个小小的坑点
x /= k, y /= k;
ll min1 = 0,min2 = 0;
if(a < x || b < y)
{
printf("0 0\n");
continue;
}
min1 = a/x;
min2 = b/y;
ll Max = min(min1,min2);
a = (Max*x),b = (Max*y);
printf("%lld %lld\n",a,b);
}
}

水题:CF16C-Monitor的更多相关文章

  1. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  4. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  5. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  6. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  7. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  8. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  9. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

随机推荐

  1. Win10 插入耳机后没有声音,拔出后电脑有声音

  2. 050 Pow(x, n)

    实现 pow(x, n).示例 1:输入: 2.00000, 10输出: 1024.00000示例 2:输入: 2.10000, 3输出: 9.26100详见:https://leetcode.com ...

  3. 常用的http网页错误代码表---------495引发的一个简单到爆,但基于国内环境只能呵呵呵的血案

    敲代码敲出了个网页错误代码 495. 然后,正常的跑去百度,看了一堆还是没有完整的网页错误代码,应该说国内的环境的网页错误代码表只有官方的那几个,那么只能FQ了. 去到谷歌,一查全是俄语,乐了,明白是 ...

  4. IQueryable和IEnumerable的区别

  5. MyBatis学习总结(三)---映射文件及引入方式

    MyBatis的强大,主要原于它强大映射功能,相对其它的jdbc,使用MyBatis,你会发现省掉很多代码.上一篇已经简单做出一个实例.今天就了解一下MyBatis的映射xml文件. 了解上一篇fri ...

  6. [Java][Web] Servlet中转发和重定向比较

    Servlet中页面跳转的两种方式 请求转发 使用requestDispatcher对象 request.getRequestDispatcher("path").forward( ...

  7. 【踩坑】Nginx上配置ssl证书实现https访问

    昨天开始为域名挂上ssl证书,使得可以以https去访问服务器.按照网上所介绍的配置Nginx,然而一直访问不了网站. 第二天排查了一早上,发现不单要配置Nginx,阿里云上安全组要开启443端口,并 ...

  8. Effective C++ 重要条款

    学习c++的童鞋们,这本书不能错过,最近在学校图书馆借来这本书,准备好好啃啃它了,先把它的基本内容过一遍吧. 改变旧有的的C习惯 条款1:尽量以const和inline取代#define. 条款2:尽 ...

  9. 初识RatingBar

    RatingBar,SeekBar和ProgressBar的子类 <RatingBar android:id="@+id/ratingBar2" android:layout ...

  10. userBean-作用范围session

    package com.java1234.model; public class Student { private String name;private int age; public Strin ...