[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 ...
随机推荐
- Python网络编程篇之socketserver
1.socketserver模块和类 socketserver是标准库中的一个高级模块,目标是简化很多样板代码(创建网络客户端和服务器所必须的代码) 这个模块封装了socket编程所需要的各种各样的类 ...
- MSSQL-并发控制-2-Isolation
如果转载,请注明博文来源: www.cnblogs.com/xinysu/ ,版权归 博客园 苏家小萝卜 所有.望各位支持! MySQL通过MVCC和锁来实现并发控制,在4 ...
- 简单的OC程序
知识点 1.#import的用途: 1> 跟#include一样,拷贝文件的内容 2> 可以自动防止文件的内容被重复拷贝 2.#import <Foundation/NSObjCRu ...
- 使用Maven Archetype插件构建Maven工程原型模板
创建原型模板 1.在空目录运行archetype:generate上面的命令,待下载完必要的jar包后,首先需要输入内置的原型编号: 1 Choose archetype: 2 1: internal ...
- 随笔-SQL的三种存储引擎即三种类型的表
MYSQL 的环境变量:......server/bin下 引擎(Engine):是电子平台上开发程序或系统的核心组件.利用引擎,开发者可迅速建立.铺设程序所需的功能,或利用其辅助程序的运转.一般而言 ...
- python中的“.T”操作
其实就是对一个矩阵的转置 看代码: a array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) a.T array([[1, 4, 7], [2, 5, 8], [3, 6, ...
- 简单使用Unity导航系统(小白之路)
1.介绍 NavMesh:是一种根据场景中几何图像创建出来的3D网格.它会使导航和寻路变得很容易. 简单来说,NavMesh是一种我们在游戏世界中,可以让游戏角色在其表面行走并且导航的平面. 2.注意 ...
- HDU 3549 Flow Problem 网络流(最大流) FF EK
Flow Problem Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Tot ...
- Git命令汇总(补充篇)
上一篇<Git命令汇总基础篇>总结了使用Git的基本命令,这一篇作为补充主要给大家讲一些平时使用中的技巧和总结 . 学会了这些命令,已经基本解决了使用Git中大部分问题. 1.gitign ...
- PHP生成 uuid
// 生成UUID,并去掉分割符 function guid() { if (function_exists('com_create_guid')){ $uuid = com_create_guid( ...