Fraction Comparision
题意:输入x,a,y,b求x/a和y/b的大小,范围long long int
思路:因为不想用精度,嫌麻烦,所以用了个巧方法。先求x/a和y/b整形的大小,如果相等,再求(x%a)*b和(y%b)*a的大小,具体为什么可以这样比较,初中生都会。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main()
{
ll x,y,a,b;
while(scanf("%lld%lld%lld%lld",&x,&a,&y,&b)!=EOF)
{
ll z1=x/a;
ll z2=y/b;
if(z1>z2)
{
printf(">\n");
}
else if(z1<z2)
{
printf("<\n");
}
else
{
ll y1=x%a;
ll y2=y%b;
ll r1=y1*b;
ll r2=y2*a;
if(r1==r2)
printf("=\n");
if(r1>r2)
printf(">\n");
if(r1<r2)
printf("<\n");
}
}
}
Fraction Comparision的更多相关文章
- ZJUT11 多校赛补题记录
牛客第一场 (通过)Integration (https://ac.nowcoder.com/acm/contest/881/B) (未补)Euclidean Distance (https://ac ...
- 2019牛客暑期多校第一场题解ABCEFHJ
A.Equivalent Prefixes 传送门 题意:给你两个数组,求从第一个元素开始到第p个元素 满足任意区间值最小的元素下标相同的 p的最大值. 题解:我们可以从左往右记录到i为止每个区间的最 ...
- 2019牛客多校 Round1
Solved:4 Rank:143 A Equivalent Prefixes 题意:求一个最大的r满足在A,B两个数组中1,r里所有的子区间RMQ相等 题解:单调队列秒 #include <b ...
- [LeetCode] Fraction to Recurring Decimal 分数转循环小数
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- 【leetcode】Fraction to Recurring Decimal
Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fra ...
- Decimal To Fraction 小数转换成分数
以0.25为例, 0.25 * 100 = 25, 求25 和 100 的最大公约数gcd. 25/gcd 为分子. 100/gcd为分母. //小数转分数 //0.3 -> 3/10, 0.2 ...
- ✡ leetcode 166. Fraction to Recurring Decimal 分数转换 --------- java
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- Leetcode 166. Fraction to Recurring Decimal 弗洛伊德判环
分数转小数,要求输出循环小数 如2 3 输出0.(6) 弗洛伊德判环的原理是在一个圈里,如果一个人的速度是另一个人的两倍,那个人就能追上另一个人.代码中one就是速度1的人,而two就是速度为2的人. ...
随机推荐
- jQuery插件3种类型
1.封装对象方法的插件 这种插件是将对象方法封装起来,用于对通过选择器获取的jQuery对象进行操作,是最常见的一种插件. 此类插件可以发挥出jQuery选择器的强大优势,有相当一部分的jQuery方 ...
- 神经网络 fann 教程 英文 以及 翻译 参考
http://fann.sourceforge.net/fann_en.pdf http://blog.csdn.net/fengshuiyue/article/details/41446257
- git查看某个文件的提交历史
1. git log --pretty=oneline 文件名 文件名是文件路径+文件名,输入完整 输入正确后,打印出版本号的列表 2. git show <git提交版本号> <文 ...
- [LeetCode] 260. Single Number III(位操作)
传送门 Description Given an array of numbers nums, in which exactly two elements appear only once and a ...
- window.location.href后携带参数
JS文件中: window.location.href后可携带参数,但是不安全,虽然在技术上是可以实现的 1.传参:window.location.href = "RecordCare.as ...
- css圣杯布局
HTML <div class="container"> <div class="content">content</div> ...
- SimplePropertyRetriever
var SimplePropertyRetriever = { getOwnEnumerables: function (obj) { return this._getProp ...
- 《JAVA设计模式》之解释器模式(Interpreter)
在阎宏博士的<JAVA与模式>一书中开头是这样描述解释器(Interpreter)模式的: 解释器模式是类的行为模式.给定一个语言之后,解释器模式可以定义出其文法的一种表示,并同时提供一个 ...
- node进程一些信号的意义
1.SIGINT这个信号是系统默认信号,代表信号中断,就是ctrl+c: 2.SIGQUIT 3.SIGTERM 4.exit
- 方法重载(overload)与方法重写(override)
一.方法重载: 在同一个类中,允许存在一个及以上的同名方法,只要他们的参数列表不同(参数的个数或者参数的类型不同)即可.注意方法重载与返回值类型.访问权限修饰符.和抛出的异常无关.重载是在本类中,与继 ...