题目链接: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 数的精度类的更多相关文章

  1. @hdu - 6607@ Easy Math Problem

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 求: \[\sum_{i=1}^{n}\sum_{j=1}^{n ...

  2. 【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),最大值点在区间 ...

  3. HDU 6182 A Math Problem

    暴力. $k$的$k$次方在$k=15$的时候,达到了最大不爆掉的情况. #include<bits/stdc++.h> using namespace std; long long an ...

  4. HDU 5055 Bob and math problem(结构体)

    主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been think ...

  5. 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 ...

  6. hdu 5105 Math Problem(数学)

    pid=5105" target="_blank" style="">题目链接:hdu 5105 Math Problem 题目大意:给定a.b ...

  7. hdu 5435 A serious math problem

    A serious math problem Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...

  8. hdu 1757 A Simple Math Problem (乘法矩阵)

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  9. HDU 5615 Jam's math problem

    Jam's math problem Problem Description Jam has a math problem. He just learned factorization.He is t ...

随机推荐

  1. Spring学习笔记(二)之装配Bean

    一,介绍Bean的装配机制 在Spring中,容器负责对象的创建并通过DI来协调对象之间的关系.但是我们要告诉Spring创建哪些Bean并且如何将其装配在一起.,装配wiring就是DI依赖注入的本 ...

  2. 了解python,利用python来制作日常猜拳,猜价小游戏

    初次接触python,便被它简洁优美的语言所吸引,正所谓人生苦短,python当歌.python之所以在最近几年越发的炽手可热,离不开它的一些特点: 1.易于学习:Python有相对较少的关键字,结构 ...

  3. [flask 优化] 由flask-bootstrap,flask-moment引起的访问速度慢的原因及解决办法

    一周时间快速阅读了400页的<javascript基础教程>,理解了主要概念.虽然对jquery.ajax.json这些方法的运用还不熟练,但在理清了概念之后解决了一个很久之前的疑问. 我 ...

  4. 【微服务】之二:从零开始,轻松搞定SpringCloud微服务系列--注册中心(一)

    微服务体系,有效解决项目庞大.互相依赖的问题.目前SpringCloud体系有强大的一整套针对微服务的解决方案.本文中,重点对微服务体系中的服务发现注册中心进行详细说明.本篇中的注册中心,采用Netf ...

  5. scrapy初试水 day01

    1.安装pip install Scrapy#一定要以管理员身份运行dos窗口conda install scrapy2.创建项目scrapy startproject hello3.在hello/s ...

  6. 揭秘 HashMap 实现原理(Java 8)

    HashMap 作为一种容器类型,无论你是否了解过其内部的实现原理,它的大名已经频频出现在各种互联网面试中了.从基本的使用角度来说,它很简单,但从其内部的实现来看(尤其是 Java 8 的改进以来), ...

  7. Ubuntu 17.04 安装

    不忘初心,方得始终. 今天听别人说17.04发布了,我是开心的不得了,赶紧下载了一个,准备安装在自己的本子上.这段时间已经花费了更多的时间在docker和OpenStack上面,没时间看新闻了,因此今 ...

  8. Python函数篇(4)之迭代器与生成器

    1.文件操作的"b模式"(补充) 在上一篇文章中,我在最后一部分写了文件处理的一些方法,但是觉得还是有必要再提一下如下的内容: 像rb.wb.ab这种模式,是以字节的形式操作,需要 ...

  9. 使用fastdfs-zyc监控FastDFS文件系统

    1.安装jdk运行环境 jdk下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 此处我使用的jdk7U99 ...

  10. salesforce零基础学习(八十四)配置篇: 自定义你的home page layout

    当我们进入salesforce系统或者切换app后,默认第一个看到的就是home页面.home页面简单的来说可以包括左侧(narrow component)和右侧(wide component)两部分 ...