题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=3555
数位dp
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #define LL long long using namespace std; const int MAXN = 30; LL f[MAXN][MAXN][2]; inline LL read(){ char c=getchar(); LL ret = 0; while (c<'0'||c>'9') c = getchar(); while (c<='9'&&c>='0'){ret=ret*10+c-'0';c=getchar();} return ret; } inline void prework(){ for (int i=0;i<=9;i++) f[1][i][0] = 1; for (int k=2,tmp=0;k<=28;k++) { for (int i=0;i<=9;i++) { for (int j=0;j<=9;j++) { if (i == 4 && j == 9) f[k][i][1] += f[k-1][j][0]; else f[k][i][0] += f[k-1][j][0]; f[k][i][1] += f[k-1][j][1]; } } } } inline LL cal(LL w){ if (!w) return 0; else { int tot = 0, arr[20]; LL ret = 0, tmp = w, t2; memset(arr,0,sizeof(arr)); while (w) arr[++tot] = w % 10, w /= 10; for (int i=1;i<tot;i++) for (int j=1;j<=9;j++) ret += f[i][j][1]; for (int i=1;i<arr[tot];i++) ret += f[tot][i][1]; for (int i=tot-1;i;i--){ for (int j=0;j<arr[i];j++) ret += f[i][j][1]; if (arr[i+1] == 4 && arr[i] == 9) { ret += tmp%(LL)(pow(10,i-1)+0.1)+1; break; } } return ret; } } int main(){ prework(); int T; T = read(); while (T--) { LL a=read(); cout<<cal(a)<<endl; } return 0; }
I truly appreciate this post. Much obliged.
Fantastic blog post. Fantastic.
I appreciate you sharing this post.Really thank you! Will read on…
Awesome article.Thanks Again. Great.
Awesome article.Really looking forward to read more. Will read on…
wow, awesome blog.Really looking forward to read more. Awesome.
A round of applause for your blog.Really looking forward to read more. Great.
Muchos Gracias for your blog post. Really Cool.
This is one awesome article.Much thanks again. Will read on…
Enjoyed every bit of your post.Much thanks again. Will read on…
I really liked your post.Really thank you!
Wow, great article post. Really Cool.
Very informative blog.Really thank you! Fantastic.
I am so grateful for your article. Will read on…
I loved your blog post. Keep writing.
Major thankies for the article post.Really thank you! Keep writing.
Fantastic blog article.Really looking forward to read more. Really Cool.
Thank you for your blog.Really looking forward to read more. Really Great.
Really enjoyed this article.Really looking forward to read more. Fantastic.
Hi, after reading this amazing article i am as well glad to share my
knowledge here with friends.
Hello would you mind letting me know which webhost you’re utilizing?
I’ve loaded your blog in 3 different web browsers and I must say
this blog loads a lot quicker then most. Can you recommend a good web hosting
provider at a fair price? Many thanks, I appreciate it!
I feel this is one of the such a lot vital info for me. And i’m satisfied reading your article.
However should statement on few general issues,
The site style is great, the articles is truly excellent : D.
Good process, cheers
This is one awesome blog.Really thank you! Really Cool.
wow, awesome post.Really thank you! Cool.
Thanks for the blog.Really thank you! Cool.
This is one awesome article.Really looking forward to read more. Will read on…
Awesome blog post.Thanks Again. Keep writing.
Great post.
Great blog post.Really looking forward to read more. Cool.
Asking questions are genuinely nice thing if
you are not understanding anything entirely, except this post gives nice understanding yet.
Appreciate you sharing, great blog post.Really thank you! Will read on…
Just want to say your article is as surprising.
The clarity in your post is just cool and i could assume you are an expert on this subject.
Well with your permission allow me to grab your feed
to keep up to date with forthcoming post. Thanks a million and please continue the
enjoyable work.
I am so grateful for your article.Really thank you! Keep writing.
Thank you ever so for you blog.Thanks Again. Want more.
Fantastic blog article.Much thanks again. Fantastic.
Enjoyed every bit of your blog.Thanks Again. Will read on…
Thank you for your post.Really looking forward to read more. Want more.
I am so grateful for your article.Thanks Again. Keep writing.
Hi, i think that i saw you visited my weblog so i came to “return the favor”.I’m trying to find things to improve my web site!I suppose
its ok to use some of your ideas!!
Im thankful for the post.Really looking forward to read more. Fantastic.
Im obliged for the blog article.Much thanks again. Will read on…
Very informative blog.Really thank you! Really Cool.
I’m gone to inform my little brother, that he should also visit
this website on regular basis to take updated from
newest news.
Very informative blog article.Much thanks again. Fantastic.
Really enjoyed this blog article.Much thanks again. Will read on…
I really like and appreciate your article.Much thanks again. Really Cool.
I really enjoy the article.Really looking forward to read more. Great.
Hi i am kavin, its my first occasion to commenting anyplace, when i read this
paragraph i thought i could also create comment due to this brilliant
piece of writing.
Im obliged for the blog. Great.
wow, awesome article.Really thank you! Great.
This info is invaluable. Where can I find out more?
Magnificent website. Lots of helpful info here. I’m sending it to
several pals ans additionally sharing in delicious. And naturally, thanks in your sweat!
Thanks for the blog post.Really looking forward to read more. Keep writing.
Wow, great article post. Much obliged.
Im obliged for the blog.Really thank you! Fantastic.
Hi, for all time i used to check webpage posts here early in the
dawn, because i enjoy to find out more and more.
Hiya very cool blog!! Man .. Beautiful .. Wonderful .. I will bookmark your site and take
the feeds also? I’m satisfied to find a lot
of useful information right here in the submit, we’d like work out
more strategies in this regard, thank you for sharing. . . .
. .
Great article.Much thanks again. Will read on…
Im obliged for the blog post. Really Great.
A big thank you for your article post.Really thank you! Really Great.
Very informative article.Really looking forward to read more. Will read on…
Thanks a lot for the article.Much thanks again. Want more.
I truly appreciate this blog article.Much thanks again. Really Great.
Appreciate you sharing, great blog article.Really looking forward to read more. Want more.
I value the blog post. Fantastic.
I really like and appreciate your article.Really looking forward to read more. Really Cool.
Major thanks for the blog post.Thanks Again. Fantastic.
Hi! I know this is kinda off topic but I was wondering which blog platform are
you using for this site? I’m getting fed up of WordPress because I’ve had problems with hackers and I’m looking at options for another platform.
I would be awesome if you could point me in the direction of a
good platform.
Thanks again for the article.Really thank you! Much obliged.
It’s an awesome paragraph for all the online visitors; they will
take benefit from it I am sure.
Perfect piece of work you have done, this internet site is really cool with fantastic information.
I really enjoy the blog.Thanks Again. Will read on…
Major thanks for the post.Much thanks again. Fantastic.
I truly appreciate this article. Fantastic.
I appreciate you sharing this post.Thanks Again.
I really liked your article post.Much thanks again. Really Cool.
Very informative article post.Really looking forward to read more. Really Cool.
Im obliged for the post.Much thanks again. Really Great.
I really enjoy the blog.Much thanks again. Fantastic.
I cannot thank you enough for the blog.Really thank you! Cool.
I am so grateful for your article post.Thanks Again. Will read on…
Im obliged for the post. Will read on…
Muchos Gracias for your post.Really looking forward to read more. Really Cool.
Hey, thanks for the blog article. Really Great.
Thanks for sharing, this is a fantastic article post.Thanks Again. Much obliged.
I really liked your blog.Thanks Again. Much obliged.
I really like it whenever people come together and share ideas.
Great blog, stick with it!
Im grateful for the blog article. Will read on…
I am so grateful for your post.Much thanks again.
Muchos Gracias for your article.
Im thankful for the post.Much thanks again. Much obliged.
A big thank you for your blog.Really thank you!
Thanks again for the article post.Really thank you! Keep writing.
New York Rapper B-Rock releases his first Dance EP . Titled ( 4 songs 4 Tha club)at CD Baby
I have read so many articles or reviews about the blogger lovers except this paragraph is in fact a nice post, keep it up.
I value the blog post.Really thank you!
Im thankful for the article.Thanks Again. Really Cool.
You made some really good points there. I checked on the internet to
find out more about the issue and found most people will go along with your views on this website.
I really like and appreciate your article post.Thanks Again. Awesome.
Ahaa, its pleasant dialogue concerning this paragraph at this
place at this web site, I have read all that, so at this time
me also commenting here.
Major thanks for the blog post.Really thank you! Will read on…
Thanks again for the blog.Really thank you! Will read on…
A round of applause for your post.Much thanks again. Great.
wow, awesome article.Really looking forward to read more. Really Cool.
Fantastic blog post.Really thank you! Fantastic.
This is one awesome blog post.Really looking forward to read more. Really Cool.
Thank you for your blog article.Really thank you! Awesome.
Thanks for sharing, this is a fantastic article.Really thank you! Cool.
I value the article post.Really thank you! Really Great.
This is one awesome blog.Much thanks again. Awesome.
Really informative article.Thanks Again.
Hello, I read your new stuff daily. Your writing style is awesome, keep it up!
Sweet blog! I found it while searching on Yahoo News. Do you
have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Appreciate it
I appreciate you sharing this article post.Really thank you! Cool.
Enjoyed every bit of your blog article.Really thank you!
I appreciate you sharing this blog.Really looking forward to read more. Really Great.
I really like and appreciate your article post.Really looking forward to read more. Fantastic.
Say, you got a nice article post. Really Great.
I really liked your article.Really thank you! Awesome.
I really like and appreciate your blog article.Much thanks again. Really Great.
Very informative post.Really looking forward to read more. Want more.
Im grateful for the blog post.Much thanks again. Fantastic.
Thanks-a-mundo for the blog article.Thanks Again. Want more.
Very neat blog.
Im thankful for the article.Much thanks again. Keep writing.
I really like and appreciate your article.Much thanks again. Great.
Hi there! I just wish to offer you a huge thumbs up for your excellent info you have here on this
post. I’ll be coming back to your web site for more
soon.
Fantastic article.Much thanks again. Really Great.
I loved your article.Really looking forward to read more. Want more.
I appreciate you sharing this blog article.Much thanks again. Really Cool.
Looking forward to reading more. Great blog article.Much thanks again. Keep writing.
Very good post.Really looking forward to read more. Awesome.
I really liked your article post.Thanks Again. Really Cool.
Major thankies for the blog article.Much thanks again. Really Cool.
I appreciate you sharing this article post. Awesome.
Looking forward to reading more. Great post.Thanks Again. Really Great.
Major thankies for the article. Awesome.
Very informative blog article.Really thank you! Cool.
Appreciate this post. Let me try it out.
Major thankies for the article. Much obliged.
Woah! I’m really enjoying the template/theme of this site.
It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between user friendliness and visual appeal.
I must say you have done a superb job with this. Additionally,
the blog loads very quick for me on Internet explorer. Outstanding Blog!
Major thanks for the blog article.Much thanks again.
I value the blog.Much thanks again.
Enjoyed every bit of your blog article.Really thank you! Fantastic.
I am so grateful for your post. Will read on…
A round of applause for your blog.Really looking forward to read more. Really Cool.
I am so grateful for your blog article.Really looking forward to read more.
I appreciate you sharing this blog article.Much thanks again. Great.
Thank you ever so for you blog post.Much thanks again. Will read on…
Awesome blog article. Awesome.
Im obliged for the blog post.Really looking forward to read more. Awesome.
A round of applause for your article.Really thank you! Really Cool.
Major thankies for the article post.Thanks Again. Much obliged.
Very neat blog post.Thanks Again. Really Cool.
Awesome post. Keep writing.
I loved your blog post.Really thank you! Awesome.
Im thankful for the blog post.Thanks Again. Cool.
I cannot thank you enough for the article.Really thank you! Really Cool.
Thank you for your blog article.Really thank you! Will read on…
Thanks again for the article. Great.
This is one awesome blog post.Really looking forward to read more. Will read on…
Muchos Gracias for your article. Great.
Thank you ever so for you blog. Great.
Say, you got a nice post.Thanks Again. Want more.
Say, you got a nice article post.Much thanks again. Great.
This is really interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your wonderful post. Also, I’ve shared your website in my social networks!
Hey, thanks for the blog post. Keep writing.
Great blog article.Really looking forward to read more. Awesome.
I cannot thank you enough for the article. Fantastic.
I loved your article post.Much thanks again. Really Cool.
Enjoyed every bit of your blog article.Much thanks again. Awesome.
I appreciate you sharing this article.Really looking forward to read more. Will read on…
Great post.Thanks Again. Fantastic.
Muchos Gracias for your article post.
Really appreciate you sharing this blog.Really thank you! Great.
I really enjoy the blog. Cool.
I really liked your blog.Thanks Again. Really Great.
Very good blog article. Keep writing.
I appreciate you sharing this blog post.Thanks Again.
This is one awesome article. Fantastic.
Thank you for your blog post.Much thanks again. Really Cool.
This is one awesome article post.Thanks Again. Great.
I really liked your blog post.Really looking forward to read more. Really Cool.
Really enjoyed this article.Thanks Again. Much obliged.
Muchos Gracias for your blog post.Thanks Again. Will read on…
Thanks so much for the blog.Really looking forward to read more. Will read on…
Hey, thanks for the blog post.Thanks Again. Really Great.
Awesome blog. Cool.
Thanks-a-mundo for the blog.Really thank you! Great.
Thank you ever so for you blog article.Really looking forward to read more. Want more.
Thanks so much for the article post.Thanks Again.
A big thank you for your blog post.Really looking forward to read more. Much obliged.
I loved your blog post.Really looking forward to read more. Will read on…
Thank you for your post.Really looking forward to read more. Really Great.
Very neat article.Really looking forward to read more. Much obliged.
Great, thanks for sharing this blog post.Really thank you! Fantastic.
Very neat blog post.Much thanks again.
Muchos Gracias for your blog article.Really thank you! Keep writing.
I appreciate you sharing this post.Really looking forward to read more. Really Cool.
Enjoyed every bit of your blog article.
Thanks for sharing, this is a fantastic post. Want more.
Really appreciate you sharing this blog. Great.
wow, awesome blog.Really looking forward to read more. Much obliged.
Thank you for your post.Much thanks again. Want more.
wow, awesome blog article.Really looking forward to read more. Cool.
This is one awesome article. Really Cool.
Very neat post.Really thank you! Great.
Thanks again for the blog article.Much thanks again. Fantastic.
I loved your article.Really thank you! Much obliged.