CF 337B - Routine Problem
来源:互联网 发布:网络空间安全 哈工大 编辑:程序博客网 时间:2024/05/04 06:32
题目 : Routine Problem
题意:给定一个a:b的屏幕,要求缩成c:d格式的(只能缩不能放),输出那条被缩的边的缩放比
思路:简单的比例安排,先把a,c或者b,d拉到统一大小,另外两者等比例变换,以a,c为例,若拉到之后有b>d就满足缩放条件了
代码:
#include "iostream"#include "cstring"#include "algorithm"#include "cmath"#include "cstdio"#include "sstream"#include "queue"#include "vector"#include "string"#include "stack"#include "cstdlib"#include "deque"#include "fstream"#include "map"using namespace std;typedef long long LL;const int INF = 0x1fffffff;const int MAXN = 1000000+100;#define eps 1e-14int gcd(int x , int y){ if(y == 0) return x; return gcd(y,x%y);}int main(){ int a,b,c,d; cin >>a >> b>>c>> d; int g1 = a*c/gcd(a,c); int g2 = b*d/gcd(b,d); int zi,mu; if(g1/a*b > g1/c*d) { zi = g1/a*b - g1/c*d; mu = g1/a*b; int t = gcd(zi,mu); cout << zi/t << '/' << mu/t << endl; } else if(g2/b*a > g2/d*c) { zi = g2/b*a - g2/d*c; mu = g2/b*a; int t = gcd(zi,mu); cout << zi/t << '/' << mu/t << endl; } else cout << 0 << '/' << a/gcd(a,b) << endl; return 0;}
- CF 337B - Routine Problem
- CF 337B(Routine Problem-公式题)
- CF#196DIV2:B-Routine Problem
- B. Routine Problem
- Codeforces Round #196 (Div. 2) / 337B Routine Problem(数学)
- CodeForces#196Div.2-B. Routine Problem
- CF 33B String Problem
- Codeforces Round #196 (Div. 2) B. Routine Problem
- Codeforces Round #196 (Div. 2) B. Routine Problem
- cf #327 Div.2 Problem B Rebranding
- CF 633B:A Trivial Problem
- cf B. Brand New Easy Problem
- cf 633b A Trivial Problem
- CF 633B A Trivial Problem
- cf 633B A trivial problem
- 【CF 706E】Working routine
- CF 706E Working routine
- CF:Problem 426B - Sereja and Mirroring 二分或者分治
- 乱码问题
- poj 1704 Georgia and Bob 博弈
- 李彦宏
- 数据可视化简介及其相关应用
- 新博客开在这里了,记录点东西
- CF 337B - Routine Problem
- 永远不要再犯的 5 个编程错误
- 黑马程序员_java基础加强(二) JDK1.5新特性
- UVa 10189 Minesweeper (模拟)
- 2013/09/21
- 马化腾
- 通过ant脚本编译打包android工程
- hdu 4750 Count The Pairs (2013南京网络赛)
- Jetty Continuation实现原理和使用场景分析