luogu#P2110. 欢总喊楼记

欢总喊楼记

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.

Problem Description

The girl gives two integers LL and RR, and she wants Huan-zong to count how many integers XX satisfy:

  • LXRL \le X \le R,
  • The most significant and least significant decimal digits of XX are equal.

For example (ignoring the restriction LXRL \le X \le R), 22, 101101, 329873329873 qualify, whereas 2323 and 45674567 do not.

Children, Huan-zong’s happiness in his next life depends on your help!

Input Format

One line containing two integers LL and RR.

Output Format

One line with a single integer, the number of XX that satisfy the property.

2 47
12

Hint

Constraints:

For 50%50\% of the testdata, 1LR1061 \le L \le R \le 10^6.

For 100%100\% of the testdata, 1LR10181 \le L \le R \le 10^{18}.

Translated by ChatGPT 5