题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2089
还是数位dp
#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 10; int f[MAXN][MAXN]; inline void prework(){ for (int i=0;i<=9;i++) f[1][i] = (i != 4); for (int k=2;k<=6;k++) { for (int i=0;i<=9;i++) { if (i == 4) continue; else for (int j=0;j<=9;j++) if (i == 6 && j == 2) continue; else f[k][i] += f[k-1][j]; } } } inline int cal(int w){ if (!w) return 0; int ret=0,tot=0,arr[MAXN]; memset(arr,0,sizeof(arr)); while (w) arr[++tot] = w % 10, w /= 10; for (int i=tot-1;i;i--) for (int j=1;j<=9;j++) ret += f[i][j]; for (int i=tot;i;i--) { for (int j=(i==tot?1:0);j<arr[i];j++) if (arr[i+1] == 6 && j == 2) continue; else ret += f[i][j]; if ((arr[i] == 2 && arr[i+1] == 6) || arr[i] == 4) break; else if (i == 1) ret ++; } return ret; } int main(){ prework(); int a,b; while (scanf("%d%d",&a,&b) && (a || b)) printf("%d\n",cal(b)-cal(a-1)); return 0; }
You have made some decent points there. I checked on the internet
for additional information about the issue and found most
individuals will go along with your views on this website.
Thank you for the good writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you! By the way, how
can we communicate?
You need to take part in a contest for one of the most useful blogs
on the web. I will highly recommend this site!
Hi to every body, it’s my first pay a quick visit
of this blog; this website includes awesome and really fine material in favor of readers.
Genuinely no matter if someone doesn’t know after that its up to other
people that they will assist, so here it occurs.
Thanks for the auspicious writeup. It in truth was a amusement account
it. Look complicated to more introduced agreeable from you!
However, how can we communicate?
Have you ever thought about adding a little bit more than just your articles?
I mean, what you say is fundamental and all.
But imagine if you added some great graphics or video clips to give your posts more, “pop”!
Your content is excellent but with pics and video clips, this website could definitely be one
of the most beneficial in its field. Very good blog!
Its like you read my mind! You seem to know a lot about this,
like you wrote the book in it or something. I think that
you could do with a few pics to drive the message home a bit,
but other than that, this is wonderful blog. A great read.
I’ll certainly be back.
Hey I know this is off topic but I was wondering
if you knew of any widgets I could add to my blog that automatically tweet my newest twitter
updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like
this. Please let me know if you run into anything. I truly enjoy reading your
blog and I look forward to your new updates.
Hello there, I found your web site by way of Google even as
searching for a comparable matter, your site came up,
it appears to be like great. I’ve bookmarked it in my
google bookmarks.
Hello there, just turned into aware of your blog thru Google, and found that it is truly informative.
I am going to be careful for brussels. I will appreciate in case you continue this
in future. A lot of other folks will likely be benefited out of your writing.
Cheers!
Hi there i am kavin, its my first time to commenting anywhere, when i read this post i
thought i could also make comment due to this sensible post.
Greetings, I believe your web site might be having browser compatibility
problems. When I look at your blog in Safari, it looks fine but when opening in I.E., it has some overlapping issues.
I merely wanted to give you a quick heads up!
Apart from that, fantastic site!
I would like to thank you for the efforts you have put in penning this
site. I’m hoping to view the same high-grade content from you
later on as well. In fact, your creative writing abilities
has encouraged me to get my very own website now 😉
I’d incessantly want to be update on new articles on this website , bookmarked! .
Thanks for sharing your thoughts about coconut oil. Regards
I needed to thank you for this wonderful read!! I certainly loved
every bit of it. I have you book marked to look at new stuff you post…
There’s certainly a great deal to find out about this topic.
I like all the points you made.
Good site you have here.. It’s difficult to find good quality writing like yours these
days. I honestly appreciate people like you! Take care!!
After checking out a handful of the blog posts on your blog, I seriously appreciate your technique of writing a blog.
I saved it to my bookmark site list and will be checking back soon. Please check
out my web site as well and tell me your opinion.
Thanks for sharing your thoughts about sling tv asksylphoflight.
Regards
Good day I am so thrilled I found your weblog, I really found you by error, while I was searching on Askjeeve for
something else, Nonetheless I am here now and would just like to say cheers for
a marvelous post and a all round enjoyable blog (I also love the
theme/design), I don’t have time to browse it all at the
moment but I have book-marked it and also added your RSS feeds,
so when I have time I will be back to read more, Please do keep
up the excellent work.
Normally I don’t read post on blogs, but I wish
to say that this write-up very compelled me to try and do so!
Your writing taste has been amazed me. Thanks, quite nice post.
I couldn’t refrain from commenting. Exceptionally
well written!
It’s genuinely very complex in this active life to listen news on TV, so I simply use web for that reason,
and get the latest information.
Great beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog web site?
The account helped me a acceptable deal. I had been a little bit
acquainted of this your broadcast offered bright clear concept
The heart of your writing whilst appearing reasonable in the beginning, did not settle well with me personally after some time. Someplace within the paragraphs you managed to make me a believer unfortunately only for a while. I nevertheless have got a problem with your leaps in assumptions and one would do nicely to fill in those gaps. When you can accomplish that, I will definitely be fascinated.