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的人. ...
随机推荐
- Vagrant 入门 - 网络
原文地址 现在,我们启动了 web 服务器,并且通过同步目录使用宿主机上的文件提供服务.然而,还只能通过虚拟机中的终端访问服务器.这一章节中,我们会使用 Vagrant 的网络特性,配置 Vagran ...
- FCKEditor添加字体
默认情况下,FCKEditor在进行文本编辑时,无法使用中文字体.自个摸索了下:打开 fckconfig.js 文件 找到第154行(应该是),会发现:FCKConfig.FontNames = 'A ...
- postman的下载和使用
postman的下载 官网:https://www.getpostman.com/downloads/ 创建账号或者用谷歌浏览器账号登录 登录之后,进行接口测试,这里请求百度为例,然后点击send,就 ...
- Python 图片格式的转换和尺寸修改
import cv2 import os import numpy as np from PIL import Image import shutil import sys image_size=14 ...
- apt-get updete以及apt-get upgrade的区别
You should first run update, then upgrade. Neither of them automatically runs the other. apt-get upd ...
- HashMap -双列集合的遍历与常用的方法
package cn.learn.Map; /* java.util.Hashtable<k,y> implements Map<k,v> 早期双列集合,jdk1.0开始 同步 ...
- uploadify多图片和文件上传网站应用
先要下载压缩包 www.uploadify.com/wp-content/uploads/files/uploadify.zip 1,模板文件引用 <!--引用jquery uploady*}- ...
- Vue2.0源码阅读笔记(四):nextTick
在阅读 nextTick 的源码之前,要先弄明白 JS 执行环境运行机制,介绍 JS 执行环境的事件循环机制的文章很多,大部分都阐述的比较笼统,甚至有些文章说的是错误的,以下为个人理解,如有错误, ...
- 获取class的儿子,报错undefined
var tds = document.getElementsByClassName("dv1")[0].children console.log(tds) 因为cla ...
- console.log的高级用法
//基本用法 console.log('最常见用法\n换行'); console.error('输出错误信息 会以红色显示'); console.warn('打印警告信息 会以黄色显示'); cons ...