牛客 数字比较E 两边取对数

 

 

 比较x^y与y^x的大小,我们知道直接比较会.....比不出来所以我们可以两边求对数

 1 #include <bits/stdc++.h>//在c++中求对数的函数是log()相当于数学中的ln 就是以e为底
 2 #define  int long long
 3 const int maxn=1e5+50;
 4 const int INF=0x3f3f3f3f;
 5 int a[maxn];
 6 using namespace std;
 7 signed main(){
 8 
 9   double x,y;
11    cin>>x>>y;
13   if(x==y)
15       cout<<"=";
17     else{
20         if((double)y*log(x)<(double)x*log(y))
21             cout<<"<";
22         else  if((double)y*log(x)>(double)x*log(y))
24            cout<<">";
26         else
28            cout<<"=";
30     }
32     return 0;
34 }

 

posted @ 2020-05-20 09:51  小靖快去敲代码  阅读(395)  评论(0编辑  收藏  举报