CoderFroces ~ 987B ~ High School: Become Human (log)

题意:给你x和y,问你x^y和y^x次方的大小。


思路:我们可以用取对数的方法进行比较,但是可能会有精度问题,所以当x==y的时候答案一定为=。



#include<bits/stdc++.h>
using namespace std;
int x, y;
int main()
{
    scanf("%d%d", &x, &y);
    char ans;
    if (y*log2(x) < x*log2(y)) ans = '<';
    if (y*log2(x) > x*log2(y)) ans = '>';
    if (y*log2(x) == x*log2(y) || x == y) ans = '=';
    printf("%c\n", ans);
    return 0;
}
/*
3 3
*/


猜你喜欢

转载自blog.csdn.net/zscdst/article/details/80528273