#C8990. Comparing Large Integers Represented as Strings
Comparing Large Integers Represented as Strings
Comparing Large Integers Represented as Strings
You are given two non-negative integers X and Y in the form of strings. The task is to determine whether X is greater than or equal to Y.
The comparison is as follows:
- If the length of X is greater than the length of Y, then X is greater than Y.
- If the length of X is less than the length of Y, then X is smaller than Y.
- If the lengths are equal, a lexicographical comparison is performed. In other words, when X and Y have the same number of digits, we compare them digit by digit from left to right.
Mathematically, if we let n be the length of X and m be the length of Y, then:
[ X \geq Y \iff \begin{cases} \text{if } n > m, & \text{then } X \geq Y, \ \text{if } n < m, & \text{then } X < Y, \ \text{if } n = m, & \text{then } X \geq Y \text{ (comparing lexicographically)}. \end{cases} ]
Your goal is to implement a solution that works for arbitrarily large integers provided as strings.
inputFormat
The input is given from stdin and consists of exactly two lines:
- The first line contains the string representation of the first large integer X.
- The second line contains the string representation of the second large integer Y.
outputFormat
Print a single line to stdout containing True
if X is greater than or equal to Y, or False
otherwise.
1234567891234567891234
123456789123456789
True