Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before.
It turns out that high school struggles are not gone. If someone is not like others, he is bullied. Vasya-8800 is an economy-class android which is produced by a little-known company. His design is not perfect, his characteristics also could be better. So he is bullied by other androids.
One of the popular pranks on Vasya is to force him to compare xyxy with yxyx. Other androids can do it in milliseconds while Vasya's memory is too small to store such big numbers.
Please help Vasya! Write a fast program to compare xyxy with yxyx for Vasya, maybe then other androids will respect him.
On the only line of input there are two integers xx and yy (1≤x,y≤1091≤x,y≤109).
If xy<yxxy<yx, then print '<' (without quotes). If xy>yxxy>yx, then print '>' (without quotes). If xy=yxxy=yx, then print '=' (without quotes).
5 8
>
10 3
<
6 6
=
In the first example 58=5⋅5⋅5⋅5⋅5⋅5⋅5⋅5=39062558=5⋅5⋅5⋅5⋅5⋅5⋅5⋅5=390625, and 85=8⋅8⋅8⋅8⋅8=3276885=8⋅8⋅8⋅8⋅8=32768. So you should print '>'.
In the second example 103=1000<310=59049103=1000<310=59049.
In the third example 66=46656=6666=46656=66.
题目:比较x^y和y^x的大小;
分析:x,y都很大,所以用log,最后可以化简为ln(x)/x。
代码如下:
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <ctime>
#define maxn 10007
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define eps 0.00000001
using namespace std;
typedef long long ll;
int main()
{
double a,b;
cin>>a>>b;
if(b*log(a)>a*log(b))
printf(">\n");
else if(b*log(a)<a*log(b))
printf("<\n");
else
printf("=\n");
return 0;
}
特判方法:
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include<ctime>
#define maxn 100007
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define eps 0.00000001
using namespace std;
typedef long long ll;
int main()
{
int a,b;
cin>>a>>b;
int s=1,flag=0;
if(a==b)
printf("=\n");
else if(a<b&&a>2&&b>2)
{
printf(">\n");
}
else if(a>b&&a>2&&b>2)
{
printf("<\n");
}
else if(a>b&&b==1)
{
printf(">\n");
}
else if(a<b&&a==1)
{
printf("<\n");
}
else if(a==2&&b==3)
{
printf("<\n");
}
else if(b==2&&a==3)
{
printf(">\n");
}
else if(a==2&&b==4||a==4&&b==2)
{
printf("=\n");
}
else if(a>b&&b==2)
{
printf("<\n");
}
else if(a<b&&a==2)
{
printf(">\n");
}
}