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 ...
随机推荐
- C++中的inline关键字
from here 1. 引入inline关键字的原因 在c/c++中,为了解决一些频繁调用的小函数大量消耗栈空间(栈内存)的问题,特别的引入了inline修饰符,表示为内联函数. 栈空间就是指放置程 ...
- fedora/centos7防火墙FirewallD详解
1 使用 FirewallD 构建动态防火墙 1.1 “守护进程” 1.2 静态防火墙(system-config-firewall/lokkit) 1.3 使用 iptables 和 ip6tabl ...
- 关于用phonegap 3.0+ 打包后sencha touch按钮点击切换动画延迟接近一秒的以及界面闪烁的解决方案
android的webview对硬件加速的支持貌似很不理想,在开启硬件加速的情况下,css3这些需要调用硬件加速的样式会大幅拖慢html5的webapp,在htc的部分手机上还会因开启硬件加速而导致闪 ...
- PostgreSQL远程代码执行漏洞(CVE-2018-1058)学习笔记
零.参考文献和绪论: 1.先知社区chybeta大神的--PostgreSQL 远程代码执行漏洞分析及利用—[CVE-2018-1058]--一文 2.博客园hunchill的--Mac 下 Post ...
- MS17-010永恒之蓝验证
一.安装MSF,windows下安装也可以,直接安装kali也可以,我是kali是攻击主机,win7是靶机,都在虚拟机里. 1.windows下安装MSF请参考:http://blog.csdn.ne ...
- 在Linux中的.iso文件的处理方法
1,mkdir /a 2,mount MLNX_OFED_LINUX-4.4-2.0.7.0-rhel7.3-x86_64.iso /a3,cd /a4,这样就可以对文件进行操作了
- linux的~和/的区别
转自:https://zhidao.baidu.com/question/166486946.html /是目录层的分隔.表示符.只有一个/表明是root,/etc/表明是根目录下面的etc目录(当然 ...
- Andorid- 反序列化,采用pull解析 xml 文件
MainActivity.java 主入口,通过获得 XML文件 ,然后将解析后的文件标签以及文本内容拼接到 StringBuffer中,最后显示在TextView上 package com.exam ...
- wampserver3 集成环境 启动Apache失败
前提:安装完成后,原先是能够启动服务,但是按照网上教程修改conf文件后就不能启动Apache, 方法: 1.查看Apache错误日志(无奈的是看不懂) 2.在cmd命令行中查看,(打开cmd,输入: ...
- 转!idea启动后发现tomcat前面出现红色或是灰色的问号
原博文地址:https://blog.csdn.net/z_zhy/article/details/83068168 直接在idea里 点击File------settings,在搜索框直接搜tomc ...