题目链接:BZOJ 1833
听说这道是一道水DP(Orz).
我到现在都不知道BZOJ上long long要用I64d输出,还是用lld输出Orz。应该是lld吧(DK)。反正我用I64d输出一直PE,改用cout就A了(这个傲娇的评测机= =)。
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define LL long long
LL A,B;
int a[30];
LL c[20],num[20];
void init(){
LL base=1;
for(int i=1;i<=12;i++){
c[i]=c[i-1]*10+base;
base*=10;
}
}
void work(LL x,LL y){
while(x){
num[x%10]+=y; x/=10;
}
}
void get(LL N,int l,int col){
LL base=1;
int i;
for(i=1;i<l;i++){
for(int j=0;j<=9;j++){
num[j]+=c[i-1]*col*9;
}
for(int j=1;j<=9;j++){
num[j]+=base*col;
}
base*=10;
}
LL now=base; i--;
while(now<N){
while(now+base<=N){
LL t=now/base;
work(t,base*col);
for(int j=0;j<=9;j++){
num[j]+=c[i]*col;
}
now+=base;
}
base/=10; i--;
}
}
void find(LL N,int col){
int tot=0;
LL temp=N;
while(temp){
a[++tot]=temp%10; temp/=10;
}
get(N,tot,col);
}
int main(){
init();
cin>>A>>B;
find(B+1,1);
find(A,-1);
for(int i=0;i<=9;i++){
cout<<num[i];
if(i!=9)printf(" ");//最后输出格式要注意啊,否则会PE
}
return 0;
}