16C
来源:互联网 发布:centos kvm 多主机 编辑:程序博客网 时间:2024/06/05 19:00
#include<bits/stdc++.h>using namespace std;int gcd(int a,int b){ return !b?a:gcd(b,a%b);}int main(){ int a,b,x,y,t,m; while(cin>>a>>b>>x>>y) { t=gcd(x,y); x/=t; y/=t; m=min(a/x,b/y); cout<<x*m<<" "<<y*m<<endl; } return 0;}
C. 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·109).
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
800 600 4 3
800 600
1920 1200 16 9
1920 1080
1 1 1 2
0 0
题意:输入一个a*b尺寸的显示器,让你把它改成x*y的显示器。也就是a/b=x/y,分数形式那种等于。
题解:x,y的范围比较大,把x:y比例gcd最简化,然后用a除以最简化的x和b除以最简化的y,取最小值。再用x*min值,y*min值就是答案。
- 16C
- C指针原理(16)-C指针基础
- codeforces 16C C. Monitor(二分)
- C语言例题16:
- 【9-16】C笔记
- 16,标准C
- CF 16 C Monitor
- c语言思想16
- c/c++ 16进制数
- C Primer Plus6-16
- 1/16 C
- 16初出茅庐C题
- 16C.Monitor
- C语言程序设计(16)
- c
- c
- c
- c
- 【Spring笔记】2. XML装配Bean
- 11.服务链路追踪(sleuth+zikpin)
- 洛谷P3384 【模板】树链剖分
- 深入理解计算机系统--笔记
- Zju1610 Count the Colors
- 16C
- 1003: 两个整数的四则运算
- OpenGL着色器程序解析--keypress
- IntelliJ IDEA创建Spring SpringMVC MyBatis整合Maven项目,并提交至Github
- JPA
- HDU 1753 大明A+B (大数加法)
- [bzoj2565][manacher][DP]最长双回文串
- Calcite-[1]-Tutorial
- EJB详解