题干
form QLU p1010
D. Pow
Description
As we all now that there’s a easy way to describe some same consecutive factors multiply each other which is POW.
For example, 2×2×2=232\times2\times2=2^32×2×2=23 and 3×3=323\times3=3^23×3=32 and it is easy to see that 23<3223<3223<32.
Now, your math teacher just gave you a problem in his class which is 10099100^{99}10099 9910099^{100}99100 which one is bigger? There are many ways to solve that and you solved it quickly. When you told the answer to your teach, he seemed to be unsatisfactory about that and he continued to asked the pow problems like that, which is given four positive integers a,b,c,da,b,c,da,b,c,d could you tell that which one is bigger between aba^bab and cdc^dcd or they are equal.
16121439447368.png
picture: some answers in the Internet
In C, you may use the function pow to calculate the answer:
pow(2,3)=8
pow(3,2)=9
Input
First line of the input contains one positive integer T(1≤T≤105)T (1\le T\le 10^5)T(1≤T≤105) indicating the number of the test cases.
Next TTT lines, each line contains four positive integers a,b,c,d(1≤a,b,c,d≤109)a,b,c,d (1\le a,b,c,d\le10^9)a,b,c,d(1≤a,b,c,d≤109)
Output
Four each test case:
if ab>cdab>cdab>cd print LEFT
else if ab=cdab=cdab=cd print EQUAL
else print RIGHT
Examples
Input
复制
3
3 2 2 3
100 99 99 100
2 4 4 2
Output
复制
LEFT
RIGHT
EQUAL
代码
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
int t;
double a,b,c,d;
cin>>t;
while (t--)
{
scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
double lf=b*log(a),ri=d*log(c);
if(lf-ri>1e-8) printf("LEFT\n");//精度控制在1e-8之间
else if(fabs(lf-ri)<=1e-8) printf("EQUAL\n");
else printf("RIGHT\n");
/* co
de */
}
system("pause");
return 0;
}