P2110 Huan-zong's Shouting Chronicle
Background
The Classic of Poetry says:
Guan-guan cries the osprey, on the islets in the river. Fair and graceful is the lady; the gentleman seeks a good mate.
It was another summer brushed by the wind... One day, while Huan-zong was studying in the library, he looked up and saw a graceful girl drift past. Truly, with one backward glance she smiled, and a hundred charms were born; the beauty of the six palaces lost their color. A wave of poetry rose in Huan-zong’s heart, and he casually wrote the verse:
Ah, you are love, warmth, and hope; you are the April of the human world!
As time slipped by, Huan-zong still could not forget that girl. People say that unrequited love is bitter, yet Huan-zong insisted on it. Night after night he struggled to sleep; could the fair lady know this heart? By chance, he learned some information about the girl. One day, Huan-zong finally gathered his courage and confessed to her!
That night was especially beautiful. Huan-zong spoke passionately downstairs; the mood was romantic and moving. The girl felt a bit touched, but would saying yes right away be a bit lacking in reserve? So, she decided to challenge Huan-zong to see how sincere he really was.
Description
The girl gives two integers $L$ and $R$, and she wants Huan-zong to count how many integers $X$ satisfy:
- $L \le X \le R$,
- The most significant and least significant decimal digits of $X$ are equal.
For example (ignoring the restriction $L \le X \le R$), $2$, $101$, $329873$ qualify, whereas $23$ and $4567$ do not.
Children, Huan-zong’s happiness in his next life depends on your help!
Input Format
One line containing two integers $L$ and $R$.
Output Format
One line with a single integer, the number of $X$ that satisfy the property.
Explanation/Hint
Constraints:
For $50\%$ of the testdata, $1 \le L \le R \le 10^6$.
For $100\%$ of the testdata, $1 \le L \le R \le 10^{18}$.
Translated by ChatGPT 5