码迷,mamicode.com
首页 > 其他好文 > 详细

两个数的次方比较

时间:2018-01-25 15:35:12      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:nal   文件   clu   output   end   numbers   index   specific   tor   

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;
}

两个数的次方比较

标签:nal   文件   clu   output   end   numbers   index   specific   tor   

原文地址:https://www.cnblogs.com/RGBTH/p/8350938.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!