During 2010 summer training, temperlisyer often does problem like this:
“Consider a decimal integer as sequence of digits {D0, D1 … Dn-1} (D0 > 0), if exists such x, y and z, satisfying:
1.Di-1<Di (0<i<=x)
2.Di-1=Di (x<i<=y)
3.Di-1<Di (y<i<=z)
4.Di-1>Di (z<i<=n-1)
We call this integer “Lanlanshu”, now give you two numbers A and B, calculate how many “Lanlanshu” are in [A, B].“
He solved so many of these and finally get bored, and then get crazy! He decided to make up a problem to put this type of problems to an end.
Give you a string str consists only by ‘/’, ‘-‘ and ‘\’, and its length is l. Consider a decimal integer as sequence of digits {D0, D1 … Dn-1} (D0 > 0), define x0=0, xl=n-1, if exists such x1, x2...xl (x0 < x1 < x2 < ... < xl) satisfying:
1. If str[i]=’/’, Dj-1<Dj (xi<j<=xi+1)
2. If str[i]=’-’, Dj-1=Dj (xi<j<=xi+1)
3. If str[i]=’\’, Dj-1>Dj (xi<j<=xi+1)
We call it Final Kichiku “Lanlanshu”, now give you two numbers A and B, calculate how many Final Kichiku “Lanlanshu” are in [A, B]. This number maybe huge, we only want to now the last 8 digits of the result.