[HDU - 5170GTY's math problem 数的精度类
题目链接:HDU - 5170GTY's math problem
题目描述
Description
GTY is a GodBull who will get an Au in NOI . To have more time to learn algorithm knowledge, he never does his math homework. His math teacher is very unhappy for that, but she can't do anything because GTY can always get a good mark in math exams. One day, the math teacher asked GTY to answer a question. There are four numbers on the blackboard - a,b,c,d. The math teacher wants GTY to compare ab with cd. Because GTY never does his homework, he can't figure out this problem! If GTY can't answer this question correctly, he will have to do his homework. So help him!
Input
Multi test cases (about 5000). Every case contains four integers a,b,c,d(1≤a,b,c,d≤1000
)separated by spaces. Please process to the end of file.
Output
Output
For each case , if ab>cd , print '>'. if ab<cd , print '<'. if ab=cd , print '='.
Sample Input
2 1 1 2
2 4 4 2
10 10 9 11
Sample Output
- =
<
解题思路
对于a^b ,这类数太大了,总的来说这是一个数的精度相关的题目,我们把数据的两边取对数,就可以解决这个问题
如果 两个数之间相差的的数小于10 的负12次方(怎样都会有误差),就可以认定两个数相等,对于这里的用到的函数fabs是针对 浮点型数据取绝对值的函数。AC代码:
#include <stdio.h> #include <math.h> #define eps 1e-12 //10的负十二次方 int main() { double a, b, c, d; while (scanf("%lf%lf%lf%lf", &a, &b, &c, &d) != EOF) { double m, n; m = b*log(a); n = d*log(c); if (a == 1 && c == 1) //等于1肯定都是相等的 { printf("=\n"); continue; } if (fabs(m - n)<eps) //对数计算后,相差只要不超过10的负十二次方,就可以认为它们相等。 printf("=\n"); else if (m>n) printf(">\n"); else if (m<n) printf("<\n"); } return 0; }
[HDU - 5170GTY's math problem 数的精度类的更多相关文章
- @hdu - 6607@ Easy Math Problem
目录 @description@ @solution@ @accepted code@ @details@ @description@ 求: \[\sum_{i=1}^{n}\sum_{j=1}^{n ...
- 【HDU 5105】Math Problem
题意 f(x)=|ax3+bx2+cx+d| 求f(x)在L≤x≤R的最大值. 分析 参数有可能是0,注意分类讨论 1.当a=0时 b=0,f为一次函数(c≠0)或者常数函数(c=0),最大值点在区间 ...
- HDU 6182 A Math Problem
暴力. $k$的$k$次方在$k=15$的时候,达到了最大不爆掉的情况. #include<bits/stdc++.h> using namespace std; long long an ...
- HDU 5055 Bob and math problem(结构体)
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been think ...
- HDU 1757 A Simple Math Problem 【矩阵经典7 构造矩阵递推式】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757 A Simple Math Problem Time Limit: 3000/1000 MS (J ...
- hdu 5105 Math Problem(数学)
pid=5105" target="_blank" style="">题目链接:hdu 5105 Math Problem 题目大意:给定a.b ...
- hdu 5435 A serious math problem
A serious math problem Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- hdu 1757 A Simple Math Problem (乘法矩阵)
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU 5615 Jam's math problem
Jam's math problem Problem Description Jam has a math problem. He just learned factorization.He is t ...
随机推荐
- Spring框架——AOP代理
我们知道AOP代理指的就是设计模式中的代理模式.一种是静态代理,高效,但是代码量偏大:另一种就是动态代理,动态代理又分为SDK下的动态代理,还有CGLIB的动态代理.Spring AOP说是实现了AO ...
- day02HTML_CSS
掌握表单标签 <form action="http://www.baidu.com" method="post"> ... </form> ...
- JavaScript提高篇之预解释作用域以及this原理及其应用
1.预解释 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- 【原创】1、简单理解微信小程序
先看下网站的运行方式: 而小程序是这样: what?就这样?是的,就这样.那小程序官方提供的Wafer,还有Wafer2...想太多了,抛弃它们吧.不应当为了解决一个简单的旧问题而去整一个复杂的新问题 ...
- 一个三维点类Gpoint3的实现
1 类设计 基本功能 (1)默认构造时,自动初始化为(0,0,0): (2)支持点之间的加.减运算: (3)支持点与常量数据的加.减.乘除运算: (4)支持点之间的相等或不能判断 (5)如果把点类看作 ...
- HDU4508--完全背包
湫湫系列故事--减肥记I Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Tot ...
- JavaScript学习总结(一)——ECMAScript、BOM、DOM(核心、浏览器对象模型与文档对象模型)
一.JavaScript简介 JavaScript是一种解释执行的脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型,它遵循ECMAScript标准.它的解释器被称为JavaScript引 ...
- select控件自动触发change事件
这里接上面的二级联动.背景:当页面跳转到修改页面时,需要首先绑定学院和专业.这就需要在页面加载时触发select的change事件,具体用trigger函数进行实现.代码如下. $("#xs ...
- appium测试准备记录
一 获取应用程序包名(手机中不安装apk) windows 环境下: aapt工具 使用aapt工具,适合给程序自动获取apk的相关信息. //aapt 是sdk自带的一个工具,在SDK/buildt ...
- 【MySQL】(4)操作数据表中的记录
1. 插入记录INSERT 方法一: INSERT [INTO] tbl_name [(clo_name,...)] {VALUES | VALUE} ({expr | DEFAULT},...),( ...