"BZOJ1833" "ZJOI2010" digit-count DP

Source: Internet
Author: User

Link:
#include <stdio.h>int main(){    puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢");    puts("网址:blog.csdn.net/vmurder/article/details/46444975");}
Exercises

However, there is no DP.
[1,r] 's answer minus [1,l] 's answer.

For a number X, ask [1,x] The answer, I was first to deal with [1,999 ... 9] Answer (that 999 ...). 9 < X)
Then swipe down to calculate how many of the highest bits I have, and how many times I have appeared in the non-highest bit.

Obviously sleep a lot every day, why still sleepy Qwq
The mosquito must be poisonous. Highly toxic.

Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace STD;Long Longans[Ten];intMain () {//Freopen ("Test.in", "R", stdin);    intI,j,k;Long LongT,y,l,r;scanf("%lld%lld", &l,&r), l--;if(l<0) ans[0]++,l=0; for(t=1, i=0, y=9; y<l;y=y*Ten+9, i++,t*=Ten) {ans[0]-=t*i*9/Ten; for(j=1;j<Ten; j + +) {ans[j]-=t*i*9/Ten;        ans[j]-=t; }    } for(t=1, i=0, y=9; y<r;y=y*Ten+9, i++,t*=Ten) {ans[0]+=t*i*9/Ten; for(j=1;j<Ten; j + +) {ans[j]+=t*i*9/Ten;        ans[j]+=t; }    } for(t=1e13, i= -; T>l;i--, t/=Ten); for(BOOLflag=1; i>=0; I--, t/=Ten)    { for(j=0;j<Ten; j + +) ans[j]-=t*i/Ten* (L/t-flag);if(flag) flag=0;Else if(l/t) ans[0]-=t; for(j=1; j<l/t;j++) ans[j]-=t; ans[l/t]-= (L +1-l/t*t), l%=t; } for(t=1e13, i= -; T>r;i--, t/=Ten); for(BOOLflag=1; i>=0; I--, t/=Ten)    { for(j=0;j<Ten; j + +) ans[j]+=t*i/Ten* (R/t-flag);if(flag) flag=0;Else if(r/t) ans[0]+=t; for(j=1; j<r/t;j++) ans[j]+=t; ans[r/t]+= (r+1-r/t*t), r%=t; }printf("%lld", ans[0]); for(i=1;i<Ten; i++)printf("%lld", Ans[i]);return 0;}

"BZOJ1833" "ZJOI2010" digit-count DP

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.