"Bzoj" "1833" "ZJOI2010" count number counts

Source: Internet
Author: User

Digital DP

Orz Iwtwiioi

Learn a bit about the new posture of using memory search to catch a problem ... But did not learn tat, and then dig a hole (mom eggs to me, the digital DP is a god hole ...) sigh

1 //Bzoj 18332#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <iostream>6#include <algorithm>7 #defineRep (i,n) for (int i=0;i<n;++i)8 #defineF (i,j,n) for (int i=j;i<=n;++i)9 #defineD (i,j,n) for (int i=j;i>=n;--i)Ten using namespacestd; OnetypedefLong LongLL; A LL Getint () { -LL v=0, sign=1;CharCh=GetChar (); -      while(ch<'0'|| Ch>'9') {if(ch=='-') sign=-1; Ch=GetChar ();} the      while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} -     returnv*=Sign ; - } - /*******************tamplate********************/ +  -  +LL f[ -],c[ -],a[ -],p[ -]; ALL DFS (intXintDigintFrontintLine ) { at     if(!x)return 0; -     if(!front &&!line && f[x]!=-1)returnF[x]; -LL last= (line a[x]:9), tot=0; -F (I,0, last) { -         if(Front && i==0) Tot+=dfs (x1, Dig,1, line&&i==Last ); -         Else if(i==dig) { in             if(I==last && Line) tot+=c[x-1]+1+dfs (x1, Dig,0, Line && i==Last ); -             Elsetot+=p[x-1]+dfs (x1, Dig,0, Line && i==Last ); to         } +         ElseTot+=dfs (x1, Dig,0,line&& i==Last ); -     } the     if(!front &&!line) f[x]=tot; *     returntot; $ }Panax Notoginseng ll Getans (ll x,ll dig) { -memset (f,-1,sizeoff); theLL t=x;intlen=0; +      while(t) a[++len]=t%Ten, t/=Ten, c[len]=c[len-1]+a[len]*p[len-1]; A     returnDFS (Len,dig,1,1); the } + intMain () { - //freopen ("Input.txt", "R", stdin); $LL a=getint (), b=getint (); $p[0]=1; F (I,1, the) p[i]=p[i-1]*Ten; -Rep (I,9) printf ("%lld", Getans (B,i)-getans (a1, i)); -printf"%lld\n", Getans (b,9)-getans (A-1,9)); the     return 0; -}
View Code

"Bzoj" "1833" "ZJOI2010" count number counts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.