B. High School: Become Human

Codeforces
IDCF987B
Time1000ms
Memory256MB
Difficulty
math
English · Original
Chinese · Translation
Formal · Original
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. ## Input On the only line of input there are two integers $x$ and $y$ ($1 \le x, y \le 10^{9}$). ## Output If $x^y &lt; y^x$, then print '_<_' (without quotes). If $x^y &gt; y^x$, then print '_\>_' (without quotes). If $x^y = y^x$, then print '_\=_' (without quotes). [samples] ## Note In the first example $5^8 = 5 \cdot 5 \cdot 5 \cdot 5 \cdot 5 \cdot 5 \cdot 5 \cdot 5 = 390625$, and $8^5 = 8 \cdot 8 \cdot 8 \cdot 8 \cdot 8 = 32768$. So you should print '_\>_'. In the second example $10^3 = 1000 &lt; 3^{10} = 59049$. In the third example $6^6 = 46656 = 6^6$.
公元2118年。机器人已经大规模生产数十年,它们为人类承担所有工作。但机器人也需要上学,才能解决创造性任务,就像以前的人类一样。 然而,高中的烦恼并未消失。如果某人与众不同,就会被欺凌。Vasya-8800 是由一家不知名公司生产的经济型机器人。它的设计并不完美,性能也欠佳,因此常被其他机器人欺凌。 其中一个流行的恶作剧是强迫 Vasya 比较 $x^y$ 和 $y^x$。其他机器人可以在几毫秒内完成,但 Vasya 的内存太小,无法存储如此巨大的数字。 请帮助 Vasya!为 Vasya 编写一个快速程序来比较 $x^y$ 和 $y^x$,也许这样其他机器人就会尊重他。 输入仅有一行,包含两个整数 $x$ 和 $y$($1 lt.eq x, y lt.eq 10^9$)。 如果 $x^y < y^x$,则输出 '_<_'(不含引号)。如果 $x^y > y^x$,则输出 '_>_'(不含引号)。如果 $x^y = y^x$,则输出 '_=_'(不含引号)。 在第一个例子中,$5^8 = 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 = 390625$,而 $8^5 = 8 dot.op 8 dot.op 8 dot.op 8 dot.op 8 = 32768$。因此你应该输出 '_>_'. 在第二个例子中,$10^3 = 1000 < 3^(10) = 59049$。 在第三个例子中,$6^6 = 46656 = 6^6$。 ## Input 输入仅有一行,包含两个整数 $x$ 和 $y$($1 lt.eq x, y lt.eq 10^9$)。 ## Output 如果 $x^y < y^x$,则输出 '_<_'(不含引号)。如果 $x^y > y^x$,则输出 '_>_'(不含引号)。如果 $x^y = y^x$,则输出 '_=_'(不含引号)。 [samples] ## Note 在第一个例子中,$5^8 = 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 dot.op 5 = 390625$,而 $8^5 = 8 dot.op 8 dot.op 8 dot.op 8 dot.op 8 = 32768$。因此你应该输出 '_>_'. 在第二个例子中,$10^3 = 1000 < 3^(10) = 59049$。 在第三个例子中,$6^6 = 46656 = 6^6$。
Given integers $ x, y \in [1, 10^9] $, compare $ x^y $ and $ y^x $. Define the function: $$ f(x, y) = \begin{cases} < & \text{if } x^y < y^x \\ > & \text{if } x^y > y^x \\ = & \text{if } x^y = y^x \end{cases} $$ To avoid direct computation of exponentially large numbers, take natural logarithms: $$ x^y < y^x \iff y \ln x < x \ln y \iff \frac{\ln x}{x} < \frac{\ln y}{y} $$ Thus, define: $$ g(t) = \frac{\ln t}{t}, \quad t > 0 $$ Then: - If $ g(x) < g(y) $, output `_<_` - If $ g(x) > g(y) $, output `_>_` - If $ g(x) = g(y) $, output `_=_` Note: $ g(t) $ is strictly increasing on $ (0, e) $ and strictly decreasing on $ (e, \infty) $, with maximum at $ t = e $. This allows for efficient comparison without floating-point precision issues for integer inputs in $ [1, 10^9] $. Compute $ \frac{\ln x}{x} $ and $ \frac{\ln y}{y} $ using high-precision floating-point arithmetic (e.g., `double`), and compare. **Special cases** to handle directly for correctness and to avoid floating-point errors: - If $ x = y $, then $ x^y = y^x $ → output `_=_` - If $ x = 1 $, then $ x^y = 1 $, $ y^x = y $ → if $ y > 1 $, then $ 1 < y $ → output `_<_` - If $ y = 1 $, then $ y^x = 1 $, $ x^y = x $ → if $ x > 1 $, then $ x > 1 $ → output `_>_` Otherwise, compute and compare $ \frac{\ln x}{x} $ and $ \frac{\ln y}{y} $.
Samples
Input #1
5 8
Output #1
\>
Input #2
10 3
Output #2
<
Input #3
6 6
Output #3
\=
API Response (JSON)
{
  "problem": {
    "name": "B. High School: Become Human",
    "description": {
      "content": "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 turn",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF987B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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.\n\nIt turn...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "公元2118年。机器人已经大规模生产数十年,它们为人类承担所有工作。但机器人也需要上学,才能解决创造性任务,就像以前的人类一样。\n\n然而,高中的烦恼并未消失。如果某人与众不同,就会被欺凌。Vasya-8800 是由一家不知名公司生产的经济型机器人。它的设计并不完美,性能也欠佳,因此常被其他机器人欺凌。\n\n其中一个流行的恶作剧是强迫 Vasya 比较 $x^y$ 和 $y^x$。其他机器人可以在几毫...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "Given integers $ x, y \\in [1, 10^9] $, compare $ x^y $ and $ y^x $.\n\nDefine the function:\n$$\nf(x, y) = \\begin{cases}\n< & \\text{if } x^y < y^x \\\\\n> & \\text{if } x^y > y^x \\\\\n= & \\text{if } x^y = y^x\n\\e...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments