Eyad was given a simple math problem, but since he is very bad at math he asked you to help him.
Given 4 numbers, a, b, c, 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.
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 a, b, c, and d (1?≤?a,?b,?c,?d?≤?109).
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; }