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