标签:include zjoi class lld space define -- www. col
https://www.luogu.org/problemnew/show/P2602
数位dp
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 const double minv=1e-10; 5 6 ll g[10],shi[15]; 7 8 void cal(ll a,ll c,int ori) 9 { 10 int i,w,s; 11 w=(log(a+minv)/log(10)); 12 i=w; 13 while (i>=0) 14 g[0]-=shi[i--]*c; 15 while (w>=0) 16 { 17 s=a/shi[w]; 18 if (w!=0) 19 for (i=0;i<10;i++) 20 g[i]+=s*shi[w-1]*w*c; 21 for (i=0;i<s;i++) 22 g[i]+=shi[w]*c; 23 g[s]+=(a%shi[w]+1)*c; 24 a=a%shi[w]; 25 w--; 26 } 27 } 28 29 int main() 30 { 31 ll a,b; 32 int i; 33 scanf("%lld%lld",&a,&b); 34 shi[0]=1; 35 for (i=1;i<=12;i++) 36 shi[i]=shi[i-1]*10; 37 cal(b,1,0); 38 cal(a-1,-1,0); 39 for (i=0;i<10;i++) 40 { 41 printf("%lld",g[i]); 42 if (i!=10) 43 printf(" "); 44 } 45 return 0; 46 } 47 /* 48 1 999 49 5 10 50 10 20 51 10 19 52 1 1000000000000 53 99 1000000000000 54 */ 55 /* 56 13 99 57 8 15 18 19 19 19 19 19 19 19 58 13 550 59 104 210 213 214 214 156 104 104 104 104 60 2 110 61 21 32 21 21 21 21 21 21 21 21 62 1 100000000 63 68888897 80000001 80000000 80000000 80000000 80000000 80000000 80000000 80000000 80000000 64 */
标签:include zjoi class lld space define -- www. col
原文地址:https://www.cnblogs.com/cmyg/p/9882743.html