No.319 happy b1rthday 2 me
タグ : / 解いたユーザー数 66
作問者 :
りあん
Note
This problem was created as the problem for day 12 of Advent Calendar Contest Advent Calendar 2015 and was published on December 12, 2015.
Please watch over it with lukewarm eyes.
Problem Statement
For positive integers $A, B(A \leq B)$, Rian-kun considered the string formed by concatenating the numbers from $A$ to $B$ in decimal notation, and decided to name it the "$(A,B)$ string".
For example, the "$(3,5)$ string" is "$345$", the "$(8,13)$ string" is "$8910111213$", and the "$(102,102)$ string" is "$102$".
Now Rian-kun has become curious about the number of contiguous substrings "$12$" contained in the "$(A,B)$ string" formed from given positive integers $A, B$.
Rian-kun, drunk from his first sip of booze, is in no state to do it, so please find in his place the number of "$12$" contained in the "$(A,B)$ string".
Input
$A$ $B$
The positive integers $A, \ B \ (1 \leq A \leq B \leq 12^{12} (= 8,916,100,448,256))$ that form the "$(A, B)$ string" are given on one line, separated by a space.
Output
Output the number of "$12$" contained in the "$(A,B)$ string" on one line.
Print a newline at the end.
Sample
Sample 1
Input
8 13
Output
1
This is the example shown in the problem statement. "$8910111213$" contains one "$12$".
Sample 2
Input
102 102
Output
0
The "$(102,102)$ string" is "$102$". Non-contiguous occurrences are not counted.
Sample 3
Input
19951212 20151212
Output
33124
Rian-kun was born on 1995/12/12 and turned 20 years old today.
Sample 4
Input
1212 121212121212
Output
15240281554
The answer may not fit in a 32-bit integer.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。