/*给出你图片的长和宽的比例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的更多相关文章

  1. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  2. 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 ...

  3. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  4. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit] ...

  8. [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 ...

  9. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

随机推荐

  1. sql语句如何删除最后一条和第一条信息

    这是先前建好的SQL数据库中的test表, sql语句: delete a from test a,(select max(id) id from test) b where a.id = b.id ...

  2. Android 监听按钮的点击事件

    onClick事件1.Button和ImageButton都拥有一个onClick事件 通过自身的.setOnClickListener(OnClickListener)方法添加点击事件2.所有的控件 ...

  3. iOS 使用AFN 进行单图和多图上传 摄像头/相册获取图片,压缩图片

    图片上传时必要将图片进行压缩,不然会上传失败 首先是同系统相册选择图片和视频.iOS系统自带有UIImagePickerController,可以选择或拍摄图片视频,但是最大的问题是只支持单选,由于项 ...

  4. Eclipse+pydev解决中文显示和注释问题的方法大全

    Eclipse+pydev解决中文显示和注释问题的方法大全 Eclipse的设置 window->preferences->general->editors->textedit ...

  5. poj_2286 IDA*

    题目大意 给定一个由数字组成的#字型网格,和一定的移动规则,问最少需要多少次移动才能达到要求的结果. 题目分析 要求最少需要几步到达结果,可以考虑广度优先搜索算法,或者迭代加深深度优先搜索(IDA*) ...

  6. ubuntu 创建桌面快捷方式

    $sudo apt-get install gnome-panel $gnome-desktop-item-edit  /home/xxx/桌面 --create-new 命令行:填入程序名称,如/u ...

  7. 【BZOJ2137】submultiple 高斯消元求伯努利数

    [BZOJ2137]submultiple Description 设函数g(N)表示N的约数个数.现在给出一个数M,求出所有M的约数x的g(x)的K次方和. Input 第一行输入N,K.N表示M由 ...

  8. ios 添加朦层

    @interface RootViewController : UIViewController { UIView *view; } -(void)createBackgroundView { vie ...

  9. java利用poi 把ppt转化为图片,

    导入jar包: poi-3.8.jar poi-ooxml-3.9.jar poi-scratchpad-3.8.jar 代码: package test4; import java.awt.Dime ...

  10. (转)Python学习路径及练手项目合集

    转载自知乎 Wayne Shi,仅仅为了方便收藏查看,侵权删. 阶段1:入门知识 零编程基础的可以先从下面几个教程了解编程及环境入门知识.(已有编程基础直接从阶段2起步) 1. 编程新手指南2. Li ...