[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 ...
随机推荐
- mysql 5.7.13 安装配置方法图文教程(linux) (转)
http://www.jb51.net/article/87160.htm ************************************************ linux环境Mysql ...
- Python学习笔记 变量
蒟蒻高举横幅:部分内容转自廖雪峰的Python教学 1.Python是动态语言,即它的变量是没有类型的. !/usr/bin/env python a = 'ABC' print a a = 123 ...
- webpack之前端性能优化(史上最全,不断更新中。。。)
最近在用webpack优化首屏加载性能,通过几种插件之后我们上线前后的速度快了一倍,在此就简单的分享下吧,先上个优化前后首屏渲染的对比图. 可以看到总下载时间从3800ms缩短到1600ms. 我们在 ...
- AJAX技术之网易滚动新闻的简单实现(附源码)--AJAX
1.AJAX简介: AJAX = Asynchronous JavaScript and XML(异步的 JavaScript 和 XML). AJAX 不是新的编程语言,而是一种使用现有标准的新方法 ...
- SQL Count(*)函数,GROUP_By,Having的联合使用
COUNT(*) 函数返回在给定的选择中被选的行数. 语法:SELECT COUNT(*) FROM table 使用:现在有一个表,名叫app_category,从Navicat中可以看到表中 ...
- 【java提高】---HashMap解析(一)
HashMap解析(一) 平时一直再用hashmap并没有稍微深入的去了解它,自己花点时间想往里面在深入一点,发现它比arraylist难理解很多,好多东西目前还不太能理解等以后自己知识更加丰富在过来 ...
- JavaScript内置的预定义函数
javascript引擎中有一组可供随时调用的内建函数.这些内建函数包括 parseInt() 将收到的任何输入值转换成整数类型输出,如果转换失败,返回NaN parseFloat() 功能基本与p ...
- 简单的基于Vue-axios请求封装
具体实现思路=>封装之前需要用npm安装并引入axios,使用一个单独的js模块作为接口请输出对象,然后export dafult 这个对象. 1.首先我们需要在Vue实例的原型prototyp ...
- Linux磁盘分区(一):添加
***********************************************声明************************************************ 原创 ...
- FastDFS教程Ⅲ-文件服务器扩容
1.简介 FastDFS文件服务器在设计时,为了支持大容量,存储节点(服务器)采用了分卷(或分组)的组织方式.存储系统由一个或多个卷组成,卷与卷之间的文件是相互独立的,所有卷的文件容量累加就是 ...