首页 技术 正文
技术 2022年11月6日
0 收藏 488 点赞 573 浏览 1220 个字

题目链接: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;}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,487
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,486
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,126
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,287