337BRoutine Problem
/*给出你图片的长和宽的比例a:b 和摄像头的比例c:d,然后叫你求最后将图片放进摄像头
以后,剩余的面积比上摄像头的总面积,注意要化简为最简形式,而且摄像头要设置成至少一条边和图片相等
做法;先将两个比例式子通分,分别比较分母和分子,通分以后必定有一条边是相等的,所以只要比较另一条边就可以了
*/
#include <iostream>
#include<string.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int gcd(int x,int y)
{
int t=;
while(t!=)
{t=x%y;x=y;y=t;}
return x;
}
void f(int a,int b)
{
int g;
g=gcd(a,b);
while(g>)
{
a/=g;
b/=g;
g=gcd(a,b);
}
if(a<b)
printf("%d/%d\n",a,b);
else
printf("%d/%d\n",b,a);
}
int int_abs(int a) {return a>?a:-a;}
int main()
{
int x,y,X,Y,g,a,b,A,B;
while(scanf("%d%d%d%d",&x,&y,&X,&Y)!=EOF)
{
a=x*Y;
b=y*Y;
A=X*y;
B=Y*y;
if(a>A)
f(abs(a-A),a>A?a:A);
else
{
a=x*X;
b=y*X;
A=X*x;
B=Y*x;
f(abs(b-B),b>B?b:B);
}
}
return ;
}
337BRoutine Problem的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
随机推荐
- 使用reduce的方法实现对象数组去重
在开发中和面试当中,数组去重问题往往是受宠儿,那用最短的代码解决这个问题会使效率得到更大的提升.普通的数组,我们可以通过filter过滤方法进行去重,详情见本人博客:http://www.cnblog ...
- PyQt4发射信号
继承自QtCore.QObject的对象均可以发射信号.如果我们单击一个按钮,那么一个clicked()信号就会被触发.下面的示例演示如何手动发射一个信号. #!/usr/bin/python # - ...
- Gamma编码及Delta编码概述
一.Elias Gamma Coding 即Gamma编码,是一种对正整数进行编码的统一编码,由Peter Elias发明.适用于预先无法获知最大编码整数的情况,而且小整数出现频率高,大整数出现频率低 ...
- js实现表单项的全选、反选以及删除操作
<html> <head> <title>test</title> <script language="javascript" ...
- 使用OpenRowSet操作Excel Excel导入数据库
使用 OpenRowSet 和 OpenDataSource 访问 Excel 97-2007 测试文件:D:\97-2003.xls和D:\2007.xlsx,两个文件的内容是一模一样的. 测试环境 ...
- 【CSS系列】布局篇
一.让设计居中 1.使用自动空白边让设计居中 <style type="text/css"> body{ text-align:center; min-width:76 ...
- 浅析HTTPS与SSL原理
版权声明:本文由盛旷 原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/134 来源:腾云阁 https://www.qclo ...
- python的三个函数(eval、exec、complie)和python版RMI
一.python的三个函数: 1.eval函数: 之前已经讲过了这个函数,该函数也类似于php的eval,例如下边这个例子 eval("os.system('id')") 但是有个 ...
- ionic开发过程中遇到的一些坑!
总结一些:在使用 ionic 开发过程中所遇到的问题. 问题一:Cannot find module '@ionic/app-scripts' 描述:使用 ionic start 项目的时候,项目安装 ...
- phpcms输出logo下拉实例
{pc:content action=" siteid="$siteid" order="listorder ASC"} {loop $data $k ...