CodeForces 16C Monitor(gcd,水题)
来源:互联网 发布:答案软件 编辑:程序博客网 时间:2024/06/05 05:06
有一批分辨率为 a * b 的显示器,要将长宽比例调整为 x : y,问应该如何缩小显示器,使缩小后的面积最大。
容易出错的地方是x 和 y 可能不互质,所以要求出最大公约数,给 x :y约分。
#include<iostream>using namespace std;int gcd(int a, int b){if(a == 0 || b == 0)return a + b;elsereturn gcd(b % a, a);}int main(){__int64 a, b, x, y;cin >> a >> b >> x >> y;int temp = gcd(x, y);x /= temp;y /= temp;if(x > a || y > b)cout << "0 0" << endl;else if(x * b > a * y){cout << a / x * x << " " << a / x * y << endl;}else if(x * b < a * y)cout << b / y * x << " " << b / y * y << endl;elsecout << a << " " << b << endl;}
- CodeForces 16C Monitor(gcd,水题)
- CodeForces 16 C.Monitor(水~)
- codeforces #16 div2 C.monitor
- codeforces 16C C. Monitor(二分)
- CodeForces 16C Monitor (简单题)
- Educational Codeforces Round 20 C || Codeforces803C Maximal GCD (水题)
- 【Codeforces 798 C】+ gcd
- Codeforces 583C GCD Table 【gcd + 构造】
- codeforces 75C C. Modified GCD(二分)
- CF 16 C Monitor
- 16C.Monitor
- Codeforces 583c GCD Table
- codeforces 583C GCD Table
- CodeForces 75C Modified GCD
- Codeforces 75 C Modified GCD
- codeforces 803C Maximal GCD
- 【Codeforces 803 C. Maximal GCD】
- codeforces 892C Pride(gcd)
- linux 基于PPP协议
- 《代码大全》读后感3
- [数据结构]线段树专辑
- PHP substr(),mb_substr()及mb_strcut的区别和用法
- maven2预编译JSP
- CodeForces 16C Monitor(gcd,水题)
- uva 10004 - Bicoloring
- CreateAnonymousThread
- CGFloat CGPoint CGSize CGRect 绘图有关的类型
- GNU info 简介
- 分享自己整理的图像处理、模式识别资料
- Android 文件复制操作及优化(cpu的占用,资源的释放)
- 薛引娟:市场越冷越要投资
- uva 11234 - Expressions