Codeforces-987B - High School: Become Human - 数论



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 $x^y$ with $y^x$. 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 $x^y$ with $y^x$ for Vasya, maybe then other androids will respect him.


On the only line of input there are two integers x and y (1 ≤ x, y ≤ 109).


If $x^y < y^x$, then print '<' (without quotes). If $x^y > y^x$, then print '>' (without quotes). If $x^y = y^x$, then print '=' (without quotes).


  给你两个数字x y,让你比较$x^y$和$y^x$的大小。



  两边同时除以$xy$:$$\frac{log_2x}{x} @ \frac{log_2y}{y}$$




#include <bits/stdc++.h>
int main() {
    int x, y, ans, flag = 1;
    scanf("%d%d", &x, &y);
    if (x == y) ans = 0;
    else if (x >= 3 && y >= 3) ans = y - x;
    else if (x <= 2 && y <= 2) ans = x - y;
    else {
        if (x > y) std::swap(x, y), flag = -1;
        if (x == 2) ans = y - 4;
        else ans = -1;
    if (ans) puts(ans * flag > 0 ? ">" : "<");
    else puts("=");
    return 0;
最后修改:2018 年 06 月 05 日 10 : 55 AM