ACM模版

描述

题解

这个题让比较 xy x y yx y x ,因为数据范围大,所以直接求肯定不行,这里可以两边取 log l o g ,这样就变成了 ylog(x) y ∗ l o g ( x ) xlog(y) x ∗ l o g ( y ) 的比较了,不过这里存在一个坑点,需要直接拿这两者进行比较,不要保存到 double d o u b l e 型的第三方变量里,因为会精度损失导致 WA W A ,(⊙o⊙)…额,我猜是精度损失导致的。

代码

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

long long x, y;

int main(int argc, const char * argv[])
{
#if DEBUG
    freopen("/Users/zyj/Desktop/input.txt", "r", stdin);
    freopen("/Users/zyj/Desktop/output.txt", "w", stdout);
#endif

    cin >> x >> y;

    if (y * log10(x) < x * log10(y))
    {
        cout << "<" << '\n';
    }
    else if (y * log10(x) > x * log10(y))
    {
        cout << ">" << '\n';
    }
    else
    {
        cout << "=" << '\n';
    }

    return 0;
}