Description
Windy defines a windy number. A positive integer that does not contain a leading 0 and the difference of at least 2 of the adjacent two digits is called the windy number. Windy would like to know the total number of windy between A and B, including A and b?
Input
Contains two integers, A B.
Output
An integer.
Sample Input"Input Sample One"
1 10
"Input Sample Two"
theSample Output"Output Example One"
9
"Output Example II"
-HINT "Data size and conventions"
100% data, meet 1 <= A <= B <= 2000000000. There's no difficulty in analyzing ideas ... But...... Is there so much detail in every bit of DP? TAT
1/**************************************************************
2 problem:1026
3User:asmdef
4language:c++
5result:accepted
6time:0 ms
7memory:804 kb
8****************************************************************/
9
Ten/***********************************************************************/
One/**********************by Asm.def-wu jiaxin*****************************/
A/***********************************************************************/
-#include <cstdio>
-#include <cstring>
the#include <cstdlib>
-#include <ctime>
-#include <cctype>
-#include <algorithm>
+#include <cmath>
-usingnamespaceStd
+typedefLongLongLL;
A#defineSetfile (x) (Freopen (#x ".", "R", stdin), Freopen (#x ". Out", "w", stdout))
at#defineGetc () GetChar ()
-template<classT>inlinevoidGETD (T &x) {
-Charch = getc ();BOOLNeg =false;
- while(!isdigit (CH) && ch! ='-') ch = getc ();
-if(ch = ='-') ch = getc (), neg =true;
-x = CH-'0';
in while(isdigit (ch = getc ())) x = x *Ten-'0'+ ch;
-if(neg) × =-X;
to}
+
-/***********************************************************************/
theintf[ A][ -], s[ A];
*InlinevoidInit () {
$ intI, J, T;
Panax Notoginsengs[0] =Ten;
- for(i =1; I <=Ten; ++i) f[0][i] =1;
the for(i =1; I <=Ten; ++i) {
+ for(j =1; J <=Ten; ++j) S[i] + = f[i][j] = s[i-1]-f[i-1][J]-f[i-1][j-1]-f[i-1][j+1];
A}
the}
+
-InlineintCalcintx) {
$if(!x)return 0;
$intx[ -], Len =0, I, j, t =0, ans =0;
- while(x) {x[len++] = X%Ten; x/=Ten;} X[len] =-1;
- for(i = len-1; I >=0;-I.) {
the for(j =1; J <= X[i];++j) {
-if(ABS (J-T) <2)Continue;
WuyiAns + = f[i][j];
the}
-if(ABS (x[i+1]-x[i]) <2) Break;
Wu if(!i) ++ans;
-t = X[i] +1;
About}
$ for(i = len-2; I >=0;-i) ans + = s[i]-f[i][1];
-returnAns
-}
-
AInlinevoidWork () {
+intA, B;
theGETD (a), getd (b);
- //while (~scanf ("%d%d", &a, &b))
$printf"%d\n", Calc (b)-Calc (A-1));
the}
the
theintMain () {
the
-#ifdef DEBUG
in//freopen ("Test.txt", "R", stdin);
the#elif!defined Online_judge
theSetfile (bzoj_1026);
About #endif
theInit ();
theWork ();
the
+#ifdef DEBUG
-printf"\n%.2lf sec \ n", (Double) clock ()/clocks_per_sec);
the #endif
Bayireturn0;
the}Digital DP
[bzoj1006] [Scoi2009]windy number (digital DP)