两个数的次方比较

Posted rgbth

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了两个数的次方比较相关的知识,希望对你有一定的参考价值。

Eyad was given a simple math problem, but since he is very bad at math he asked you to help him.

Given 4 numbers, abc, and d. Your task is to find whether ab is less than cd or not.

It is guaranteed that the two numbers above are never equal for the given input.

Input

The first line contains an integer T (1?≤?T?≤?105), where T is the number of test cases.

Then T lines follow, each line contains four integers abc, and d (1?≤?a,?b,?c,?d?≤?109).

Output

For each test case, print a single line containing "<" (without quotes), if ab is less than cd. Otherwise, print ">" (without quotes).

题意:

给你四个整数a,b,c,d,比较a的b次方和c的d次方的大小。

gym上的一道题,用long double并取对数就好了。

CE了两次,要记住log函数要用数学函数头文件了。

#include<iostream>
#include<map>
#include<algorithm>
#include<string>
#include<cstdio>
#include<vector>
#include<functional>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long
#define kg " "
int main()
{
    ll a,b,c,d;
    int t;
    cin>>t;
    while(t--){
         cin>>a>>b>>c>>d;
    long double e,f;
    e=b*log(a);
    f=d*log(c);
    if(e>f)
        cout<<">"<<endl;
        else
            cout<<"<"<<endl;
    }


    return 0;
}

以上是关于两个数的次方比较的主要内容,如果未能解决你的问题,请参考以下文章

AcWing 790. 数的三次方根

AcWing 790. 数的三次方根

浮点数二分模板题---数的三次方根

任意数的整数次方

数的每一位平方和

数的每一位平方和